ZfcUserAdmin
ZfcUserAdmin copied to clipboard
Column not found: 1054 Unknown column 't0.user_id' in 'where clause'
Installed modules:
array(2) {
["modules"] => array(12) {
[0] => string(18) "ZendDeveloperTools"
[1] => string(14) "DoctrineModule"
[2] => string(17) "DoctrineORMModule"
[3] => string(7) "ZfcBase"
[4] => string(7) "ZfcUser"
[5] => string(18) "ZfcUserDoctrineORM"
[6] => string(7) "ZfcRbac"
[7] => string(8) "ZfcAdmin"
[8] => string(12) "ZfcUserAdmin"
[9] => string(11) "Application"
[10] => string(9) "TwbBundle"
[11] => string(11) "ZfcDatagrid"
}
When trying to edit an user I get the following error:
Column not found: 1054 Unknown column 't0.user_id' in 'where clause'
Caused by the following query:
SELECT t1.username AS username2, t1.email AS email3, t1.display_name AS display_name4, t1.password AS password5, t1.state AS state6, t1.user_id AS user_id7 FROM user t1 WHERE t0.user_id = ?' with params ["17"]:
For some reason the query uses t1 as alias for the user table but then queries on an t0 alias for the user_id.
I recognized that the error only occurs when using my custom User Model Entity Class set in zfuser.global.php. By default everything works fine.
My custom entity extends the ZfcUserDoctrineORMEntity and implements the ZfcRbac IdentityInterface:
/**
* An example of how to implement a role aware user entity.
*
* @ORM\Entity
* @ORM\Table(name="user")
*
* @author Tom Oram <[email protected]>
*/
class User extends ZfcUserDoctrineORMEntity implements IdentityInterface
{
/**
* {@inheritDoc}
*/
public function getRoles()
{
// here goes the logic for getting roles from identity
return array('guest', 'admin');
}
}
So far I can see no reason why Doctrine would create two aliases for this one query.
It looks like a problem with extending the ZfcUserDoctrineORMEntity. It works fine when only extending the ZfcUserEntity.
Maybe the ZfcUserDoctrineORM module somehow injects the ZfcUserEntity making Doctrine resp. the repository think there are two tables which one alias each (t0 and t1)?