Symfony and doctrine request - php

I'm trying to get all Tickets with "Destinataire" equal to a "Compte":
$ret = $repository->findByDestinataires($compte->getId());
My problem is that I get an error:
An exception occurred while executing 'SELECT t0.id AS id_1, t0.Titre AS Titre_2, t0.DateCreation AS DateCreation_3, t0.DateButoire AS DateButoire_4, t0.DateFin AS DateFin_5, t0.Priorite AS Priorite_6, t0.Commentaire AS Commentaire_7, t0.Statut AS Statut_8, t0.emeteur_id AS emeteur_id_9, t0.client_id AS client_id_10 FROM ticket t0 WHERE ticket_compte.compte_id = ?' with params [1]:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'ticket_compte.compte_id' in 'where clause'
I have two tables like this:
Compte:
namespace CommonBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Compte
*
* #ORM\Table(name="compte")
* #ORM\Entity(repositoryClass="CommonBundle\Repository\CompteRepository")
*/
class Compte
{
/**
* #var int
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
public $id;
/**
* #var string
*
* #ORM\Column(name="Nom", type="string", length=80)
*/
public $nom;
/**
* #var string
*
* #ORM\Column(name="Prenom", type="string", length=80)
*/
public $prenom;
/**
* #var string
*
* #ORM\Column(name="Fonction", type="string", length=80)
*/
public $fonction;
/**
* #var string
*
* #Assert\NotBlank()
* #ORM\Column(name="Pseudo", type="string", length=80)
*/
public $pseudo;
/**
* #var string
*
* #Assert\NotBlank()
* #ORM\Column(name="MotDePasse", type="string", length=80)
*/
public $motDePasse;
/**
* #ORM\ManyToOne(targetEntity="CommonBundle\Entity\Profil", cascade={"persist"})
* #ORM\JoinColumn(nullable=false)
*/
public $profil;
/**
* #ORM\ManyToMany(targetEntity="CommonBundle\Entity\Ticket", cascade={"persist"})
*/
public $tickets;
}
Ticket:
namespace CommonBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Ticket
*
* #ORM\Table(name="ticket")
* #ORM\Entity(repositoryClass="CommonBundle\Repository\TicketRepository")
*/
class Ticket
{
/**
* #var int
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
public $id;
/**
* #var string
*
* #ORM\Column(name="Titre", type="string", length=80)
*/
public $titre;
/**
* #var \DateTime
*
* #ORM\Column(name="DateCreation", type="datetimetz")
*/
public $dateCreation;
/**
* #var \DateTime
*
* #ORM\Column(name="DateButoire", type="datetimetz")
*/
public $dateButoire;
/**
* #var \DateTime
*
* #ORM\Column(name="DateFin", type="datetimetz", nullable=true)
*/
public $dateFin;
/**
* #var int
*
* #ORM\Column(name="Priorite", type="integer")
*/
public $priorite;
/**
* #var string
*
* #ORM\Column(name="Commentaire", type="text")
*/
public $commentaire;
/**
* #var int
*
* #ORM\Column(name="Statut", type="integer")
*/
public $statut;
/**
* #ORM\ManyToOne(targetEntity="CommonBundle\Entity\Compte", cascade={"persist"})
* #ORM\JoinColumn(nullable=false)
*/
public $emeteur;
/**
* #ORM\ManyToMany(targetEntity="CommonBundle\Entity\Compte", cascade={"persist"})
* #ORM\JoinColumn(nullable=true)
*/
public $destinataires;
/**
* #ORM\ManyToOne(targetEntity="CommonBundle\Entity\Client")
* #ORM\JoinColumn(nullable=true)
*/
public $client;
}
And there links:
compte_ticket //for "emeteure"
->ticket_id compte_id
ticket_compte //for "destinataires"
->ticket_id compte_id
I've tried the same request directly on the server and got the same error.
Is it the PHP code that is wrong?
Or maybe the entities...
INFO:
I've not put all the get/set from Compte or Ticket on purpose. If it's needed I'll edit.

http://doctrine-orm.readthedocs.org/projects/doctrine-orm/en/latest/reference/working-with-objects.html
It seem the that the shortcut method you are using (findByDestinataires) is only designed to get related records from the owning side of a relationship and hence only one 2 many not many 2 many.
You will need to create a custom query for this.
Here is one I knocked up quickly, add the following function to your TicketRepository
public function getTicketsByCompteId($compte_id)
{
return $this->getEntityManager()
->createQuery(
"SELECT t, d FROM AppBundle:Ticket t
LEFT JOIN t.destinataires d
WHERE
d.id = :compte_id"
)
->setParameter('compte_id', $compte_id)
->getResult();
}
And then call it from your controller:
$ret = $repository->getTicketsByCompteId($compte->getId());

Sounds like the foreign key field is not created. Did you run
php app/console doctrine:schema:update --force --dump-sql
After adding your relationships?

Related

Table join with entity (Symfony)

I'm new to Symfony and am having trouble getting my entities set up. I want to be able to access the tag names from my Acasset entity.
Here are the relevant entities:
class Actag
{
/**
* #var string
*
* #ORM\Column(name="tag_name", type="string", length=200, nullable=true)
*/
private $tagName;
/**
* #var integer
*
* #ORM\Column(name="tag_id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $tagId;
/**
* Acassettag
*
* #ORM\Table(name="acAssetTag", indexes={#ORM\Index(name="IDX_7C4A2A745DA1941", columns={"asset_id"}), #ORM\Index(name="IDX_7C4A2A74BAD26311", columns={"tag_id"})})
* #ORM\Entity
*/
class Acassettag
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* #var \AdminBundle\Entity\Acasset
*
* #ORM\ManyToOne(targetEntity="AdminBundle\Entity\Acasset", inversedBy="asset", cascade="PERSIST")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="asset_id", referencedColumnName="asset_id")
* })
*/
private $asset;
/**
* #var \AdminBundle\Entity\Actag
*
* #ORM\ManyToOne(targetEntity="AdminBundle\Entity\Actag")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="tag_id", referencedColumnName="tag_id")
* })
*/
private $tag;
/**
* Acasset
*
* #ORM\Table(name="acAsset", indexes={#ORM\Index(name="IDX_3B81679E68BA92E1", columns={"asset_type"}), #ORM\Index(name="IDX_3B81679E12469DE2", columns={"category_id"})})
* #ORM\Entity(repositoryClass="AdminBundle\Repository\AcAssetRepository")
*/
class Acasset
{
/**
* #var string
*
* #ORM\Column(name="asset_name", type="string", length=100, nullable=false)
*/
private $assetName;
/**
* #var integer
*
* #ORM\Column(name="asset_id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $assetId;
/**
* #var \AdminBundle\Entity\Acassettype
*
* #ORM\OneToOne(targetEntity="AdminBundle\Entity\Acassettype", mappedBy="asset", fetch="EAGER", cascade={"persist"})
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="asset_type_id", referencedColumnName="asset_type_id")
* })
*/
private $assetType;
/**
* #var \AdminBundle\Entity\Actag
*
* #ORM\ManyToOne(targetEntity="AdminBundle\Entity\Actag")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="tag_id", referencedColumnName="tag_id")
* })
*/
private $assetTags;
/**
* Set tag
*
* #param \AdminBundle\Entity\Actag $tag
*
* #return Acassettag
*/
public function setAssetTags(\AdminBundle\Entity\Actag $tag = null)
{
$this->tag = $tag;
return $this;
}
/**
* Get tag
*
* #return \AdminBundle\Entity\Actag
*/
public function getAssetTags()
{
return $this->tag;
}
So in my Acasset entity I have created $assetTags but I am getting an error: Invalid column name 'tag_id'.
But $tag in the Acasettag entity works, which is set up the same way. What am I missing, still struggling a little with this part of Symfony.
I didnt't include all the getters and setters in this post, just the one I created for this.
Why does your Actag-Entity hat also a tagId field? You don't need a defined Id-Column on the Owning-Side. You have to define a OneToMany.
Many Acassettag are owned by one Actag (because of the ManyToOne-Definition in Acassettag
So every Acassettag will need the field actag_id with the Id of the owning Actag which will be autogenerated by your ManyToOne-Definition
When you create a new Acassettag Entity and want to "connect" it with a existing Actag you need Acassettag
public setActag(Actag $actag)
{
$this->tag = $actag;
return $this;
}

I can't build a specific request in the repository with querybuilder

I have 3 tables "User", "Events" an "typeEvents" I would like to get a list of user with one where (ex : type = "Festival").
As well user entity is in another bundle that Events and typeEvents. but this is not the problem.
In one of Entity, I have a manyToMany relationship...so I can't do this query builder request.
User.php :
class User extends BaseUser
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* #var string
*
* #ORM\Column(name="pseudo", type="string", length=30, nullable=true)
*/
private $pseudo;
/**
* #ORM\Column(name="name", type="string", length=255)
*
* #Assert\NotBlank(message="Please enter your name.", groups={"Registration", "Profile"})
* #Assert\Length(
* min=3,
* max=255,
* minMessage="The name is too short.",
* maxMessage="The name is too long.",
* groups={"Registration", "Profile"}
* )
*/
private $name;
/**
* #var ArrayCollection $events
* #ORM\OneToMany(targetEntity="BISSAP\BenevolesBundle\Entity\Events", mappedBy="user", cascade={"persist", "remove", "merge"})
*/
private $events;
[...]
Events.php:
class Events
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
*
* #ORM\ManyToOne(targetEntity="TypeEvents", inversedBy="events", cascade={"persist"})
*
*/
private $typeEvents;
/**
*
* #ORM\ManyToOne(targetEntity="GenreEvents", inversedBy="events", cascade={"persist"})
*
*/
private $genreEvents;
/**
*
* #ORM\ManyToOne(targetEntity="BISSAP\UserBundle\Entity\User", inversedBy="events", cascade={"persist"})
*
*/
private $user;
[...]
TypeEvents.php:
class TypeEvents
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var ArrayCollection $events
* #ORM\OneToMany(targetEntity="Events", mappedBy="typeEvents", cascade={"persist", "remove", "merge"})
*/
private $events;
/**
* #var string
*
* #ORM\Column(name="type", type="string", length=255)
*/
public $type;
[...]
So in the userRepository I'm trying with :
public function findUserEvent()
{
$qb = $this
->createQueryBuilder('u')
->leftJoin('u.events', 'ev')
->addSelect('ev')
->where('BISSAPBenevolesBundle:TypeEvents.type = :type')
->setParameter('type', 'Festival')
;
return $qb->getQuery()->getResult();
}
And I get this error : [Semantical Error] line 0, col 78 near 'BISSAPBenevolesBundle:TypeEvents.type': Error: 'BISSAPBenevolesBundle:TypeEvents' is not defined.
Try with:
public function findUserEvent()
{
$qb = $this
->createQueryBuilder('u')
->leftJoin('u.events', 'ev')
->leftJoin('ev.types', 'evt')
->where('evt.type = :type')
->setParameter('type', 'Festival')
;
return $qb->getQuery()->getResult();
}
Hope this help

Can't Create association on Symfony2

I'm trying to create a "OneToMany" bidirectional association in my project but when I execute "doctrine:schema:update" nothing happens.
If I create this association directly from Sequel Pro and run the update schema command, that changes dissapear... :/
The relations is:
- One "id" from Customers Table with many "customer_id" form Control table.
Here is the Customers code:
<?php
namespace Ourentec\CustomersBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
* Customers
*
* #ORM\Table()
* #ORM\Entity
*/
class Customers
{
/* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var string
*
* #ORM\Column(name="name", type="string", length=100)
*/
private $name;
/**
* #var string
*
* #ORM\Column(name="lastname", type="string", length=100)
*/
private $lastname;
/**
* #var string
*
* #ORM\Column(name="address", type="text")
*/
private $address;
/**
* #var string
*
* #ORM\Column(name="phone", type="string", length=100)
*/
private $phone;
/**
* #var string
*
* #ORM\Column(name="pass", type="string", length=100)
*/
private $pass;
/**
* #var string
*
* #ORM\Column(name="tasks", type="text")
*/
private $tasks;
/**
* #var string
*
* #ORM\Column(name="status", type="string", length=100)
*/
private $status;
/**
* #var string
*
* #ORM\Column(name="email", type="string", length=100)
*/
private $email;
/**
* #var \DateTime
*
* #ORM\Column(name="date", type="datetime")
*/
private $date;
/**
* #var string
*
* #ORM\Column(name="location", type="string", length=100)
*/
private $location;
/**
* #ORM\OneToMany(targetEntity="Control", mappedBy="customers")
*/
private $customer_id;
public function __construct()
{
$this->customer_id = new ArrayCollection();
}
And the Control code:
<?php
namespace Ourentec\CustomersBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Control
*
* #ORM\Table()
* #ORM\Entity
*/
class Control
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var integer
*
* #ORM\Column(name="customer_id", type="integer")
*
* #ORM\ManyToOne(targetEntity="Customers", inversedBy="control")
* #ORM\JoinColumn(name="customer_id", referencedColumnName="id")
*/
private $customerId;
/**
* #var integer
*
* #ORM\Column(name="user_id", type="integer")
*/
private $userId;
/**
* #var \DateTime
*
* #ORM\Column(name="date", type="datetime")
*/
private $date;
/**
* #var integer
*
* #ORM\Column(name="seen", type="smallint")
*/
private $seen;
I followed the documentation from this 2 websites
http://symfony.com/doc/current/book/doctrine.html
http://librosweb.es/libro/symfony_2_x/capitulo_8/relaciones_y_asociaciones_de_entidades.html
But I don't know why it does not work..
Any idea will be appreciated :)
Mapping are not correct, I will try to explain how it works.
In Customers entity (you should rename it to Customer, entites names are singular)
/**
* #ORM\OneToMany(targetEntity="Control", mappedBy="customer")
*/
private $controls;
Mapped by option defines field name in the other entity.
/**
* #var integer
*
* #ORM\Column(name="customer_id", type="integer")
*
* #ORM\ManyToOne(targetEntity="Customers", inversedBy="controls")
* #ORM\JoinColumn(name="customer_id", referencedColumnName="id")
*/
private $customer;
Same thing with inversedBy.
In Customers entity you also need to init controls var as an ArrayCollection:
public function __construct()
{
$this->controls = new ArrayCollection();
}
With these mappings schema should be updated correctly.
For more info, check doctrine docs.

symfony2 how to get mapping table id?

how to get mapping table id from mappipng table?
i have user and group table mapped together
and i want to get group id at login time but i am not getting it.
i have three table
user, group, user_groupname
->first table
user
id,name
->second table
group
id,name
->third table
groupname
user_id,group_id
first entity is as follows
/Entity/groupname.php
class groupname
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer", nullable=false)
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* #var string
*
* #ORM\Column(name="name", type="string", length=255, nullable=false)
*/
private $name;
/**
* #var \Doctrine\Common\Collections\Collection
*
* #ORM\ManyToMany(targetEntity="role", inversedBy="groupname")
* #ORM\JoinTable(name="groupname_role",
* joinColumns={
* #ORM\JoinColumn(name="groupname_id", referencedColumnName="id")
* },
* inverseJoinColumns={
* #ORM\JoinColumn(name="role_id", referencedColumnName="id")
* }
* )
*/
private $role;
/**
* #ORM\ManyToMany(targetEntity="\Dashboard\SecurityBundle\Entity\User", mappedBy="groupname")
*/
private $users;
}
second entity is as follows
/Entity/User.php
<?php
namespace Dashboard\SecurityBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\AdvancedUserInterface;
use Doctrine\Common\Collections\ArrayCollection;
/**
* Dashboard\SecurityBundle\Entity\User
*
* #ORM\Table(name="users")
* #ORM\Entity(repositoryClass="Dashboard\SecurityBundle\Repository\UserRepository")
* #ORM\HasLifecycleCallbacks()
*/
class User implements UserInterface, \Serializable, AdvancedUserInterface
{
/**
* #ORM\Column(type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* #ORM\Column(type="string", length=25, unique=true)
*/
protected $username;
*/
/**
* #ORM\ManyToMany(targetEntity="\Dashboard\AdminManageUserBundle\Entity\groupname", inversedBy="users")
*
*/
public $groupname;
/**
* #var Dashboard\SecurityBundle\Entity\UserPhoto UserPhoto
*
*/
private $userPhoto;
public function __construct()
{
$this->groupname = new ArrayCollection();
}
/**
* Add groupname
*
* #param \Dashboard\AdminManageUserBundle\Entity\groupname $groupname
* #return User
*/
public function addGroupname(\Dashboard\AdminManageUserBundle\Entity\groupname $groupname)
{
$this->groupname[] = $groupname;
return $this;
}
/**
* Remove groupname
*
* #param \Dashboard\AdminManageUserBundle\Entity\groupname $groupname
*/
public function removeGroupname(\Dashboard\AdminManageUserBundle\Entity\groupname $groupname)
{
$this->groupname->removeElement($groupname);
}
/**
* Get groupname
*
* #return \Doctrine\Common\Collections\ArrayCollection
*/
public function getGroupname()
{
return $this->groupname;
}
}
and i have following code right in Controller file
$userEntity = $this->getDoctrine()->getRepository('DashboardSecurityBundle:User')->findOneBy(array('username' =>$usernames));
and i have print_R($userEntity) pc got hanged
$userEntiry is a object of UserEntity
So, your pc got hanged.
please try this.
print_r($userEntity->getUsername());

Doctrine2 Association Persistence

I've been playing around with Zend and Doctrine incorporated into it for the past week or so. I've gotten the hang of basic inserts and selects, and can also use DQL to select from joined tables. The problem I'm having is persisting associated entities. Error I'm getting is this: (path)htdocs\vendor\doctrine\common\lib\Doctrine\Common\Persistence\Mapping\MappingException.php:96 with the message 'Class "" does not exist'.
My code is below...
Here is the main entity (the one on the "many" side)
namespace Project\Entity;
use Doctrine\ORM\Mapping as ORM;
use Zend\InputFilter\Factory as InputFactory;
/**
* ClientUser
*
* #ORM\Table()
* #ORM\Entity
*/
class ClientUser extends SystemUser
{
/**
* #var integer
*
* #ORM\OneToOne(targetEntity="SystemUser", cascade={"persist", "remove"})
* #ORM\JoinColumn(name="id", referencedColumnName="id")
*/
private $id;
/**
* #var integer
*
* #ORM\ManyToOne(targetEntity="Client", cascade={"persist", "remove"})
* #ORM\JoinColumn(name="client", referencedColumnName="id")
*/
private $client;
protected $_inputFilter;
//Other stuff here...
}
Here is the "Client" associated entity...
namespace Project\Entity;
use Doctrine\ORM\Mapping as ORM;
use Zend\InputFilter\InputFilter;
use Zend\InputFilter\Factory as InputFactory;
use Zend\InputFilter\InputFilterAwareInterface;
use Zend\InputFilter\InputFilterInterface;
/**
* Client
*
* #ORM\Table()
* #ORM\Entity
*/
class Client implements InputFilterAwareInterface
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var string
*
* #ORM\Column(name="client_name", type="string", length=255)
*/
private $clientName;
/**
* #var integer
*
* #ORM\Column(name="loggable_hours", type="integer")
*/
private $loggableHours;
/**
* #var float
*
* #ORM\Column(name="normal_rate", type="decimal", scale=2)
*/
private $normalRate;
/**
* #var float
*
* #ORM\Column(name="critical_rate", type="decimal", scale=2)
*/
private $criticalRate;
/**
* #var string
*
* #ORM\Column(name="start_date", type="string")
*/
private $startDate;
/**
* #var boolean
*
* #ORM\Column(name="enabled", type="boolean")
*/
private $enabled;
/**
* #var integer
*
* #ORM\Column(name="critical_hours", type="integer")
*/
private $criticalHours;
/**
*
* #var type
*/
protected $_inputFilter;
//Other stuff (getters,setters, etc)
}
The ClientUser has a one-to-one relationship with the following:
namespace Project\Entity;
use Doctrine\ORM\Mapping as ORM;
use Zend\InputFilter\InputFilter;
use Zend\InputFilter\Factory as InputFactory;
use Zend\InputFilter\InputFilterAwareInterface;
use Zend\InputFilter\InputFilterInterface;
/**
* SystemUser
*
* #ORM\Table()
* #ORM\Entity
* #ORM\InheritanceType("JOINED")
* #ORM\DiscriminatorColumn(name="user_type", type="integer")
* #ORM\DiscriminatorMap({1 = "DeveloperUser", 2 = "ClientUser"})
*
*/
class SystemUser implements InputFilterAwareInterface {
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var string
*
* #ORM\Column(name="username", type="string", length=100, unique=true)
*/
private $username;
/**
* #var string
*
* #ORM\Column(name="password", type="string", length=255)
*/
private $password;
/**
* #var string
*
* #ORM\Column(name="user_first_name", type="string", length=255)
*/
private $userFirstName;
/**
* #var string
*
* #ORM\Column(name="user_surname", type="string", length=255)
*/
private $userSurname;
/**
* #ORM\Column(type="string", length=32)
*/
private $salt;
/**
* #var \DateTime
*
* #ORM\Column(name="last_login", type="datetime")
*/
private $lastLogin = '0000-00-00 00:00:00';
/**
* #var bool
*
* #ORM\Column(name="enabled", type="boolean", options={"default" = 1})
*/
private $enabled = 1;
/**
* For the input filter...
*
* #var InputFilter
*/
protected $_inputFilter;
//The rest...
}
I have absolutely no idea what could be wrong here... Just for completeness, here is the controller "add" action...
public function addAction() {
//To add clients
$form = new ClientUserForm($this->getServiceLocator()
->get('Doctrine\ORM\EntityManager'));
$form->get('submit')->setValue('Add');
$request = $this->getRequest();
if ($request->isPost()) {
$clientUser = new ClientUser();
$form->setInputFilter($clientUser->getInputFilter());
$form->setData($request->getPost());
if ($form->isValid()) {
$clientUser->populate($form->getData());
/**
*This bottom line is where I get the exception!
*/
$this->getEntityManager()->persist($clientUser);
$this->getEntityManager()->flush();
//Redirect
return $this->redirect()->toRoute('client_user');
}
}
return array ('form' => $form);
}
Any help would be awesome! If I just knew which class "" is supposed to be, I'd probably be in a better place than I am now!
Thanks ladies and gents, you guys rock!
EDIT-
Forgot to add these 2 PHP warnings...
Warning: spl_object_hash() expects parameter 1 to be object, integer given in (path)\htdocs\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php on line 1588
Warning: get_class() expects parameter 1 to be object, integer given in (path)\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php on line 1596
Im not sure of what could be happening, but i find something that i dont understand. When you states the inheritance, you use:
* #ORM\DiscriminatorColumn(name="user_type", type="integer")
* #ORM\DiscriminatorMap({1 = "DeveloperUser", 2 = "ClientUser"})
but
there isnt a class called DeveloperUser
and also
are you sure that in the database, all user_type are just 1 or 2? (no null, not 0, etc)

Categories