Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Column not found: 1054 Unknown column 't0.user_id' in 'where clause' #47

Open
webdevilopers opened this issue Apr 29, 2014 · 2 comments

Comments

@webdevilopers
Copy link

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.

@webdevilopers
Copy link
Author

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.

@webdevilopers
Copy link
Author

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)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant