I am using the class table inheritance pattern with Doctrine 2.2. My DB schema is as follows:
Parent
access_id (primary key)
access_type (discriminator column)
access_role
access_acl
access_primary
user_id (foreign key)
Child 1
access_id (foreign key)
account_id (foreign key)
Child 2
access_id (foreign key)
distributor_id (foreign key)
When I try to insert a new entity into the database, the parent query looks okay, but the child query has an extra parameter. When I dumped the query being executed, this is what I saw:
INSERT INTO user_access_account (access_id, account_id) VALUES (?, ?)
array('1'=> 39, '2'=> NULL, '3'=> 3 )
The '2' index is extraneous. '1' => 39, '2' => 3 are the correct parameters.
The code used to execute this query is as follows:
$entity = new Entity\UserAccessAccount();
$entity->setAccount($account)
->setUser($user)
->setAccessRole($accessRole)
->setAccessAcl($accessAcl)
->setAccessPrimary($accessPrimary);
$em->persist($entity);
$em->flush($entity);