Danielss89
Danielss89

Reputation: 863

Doctrine2 using wrong table

I have a doctrine 2 User entity which i try to find using an email.

This is the code:

enter image description here

This is the query i get

SELECT t1.username AS username2, t1.email AS email3, t1.display_name AS display_name4,     t1.password AS password5, t1.user_id AS user_id6, t1.surname AS surname7, t1.lastname AS lastname8, t1.avatar AS avatar9, t1.phone AS phone10, t1.birthday AS birthday11, t1.title AS title12, t1.salon AS salon13
FROM user t1
WHERE t0.email = ?
LIMIT 1

So where does it get t0 from? it uses t1 everywhere else?

The error i get is

SQLSTATE[42S22]: Column not found: 1054 Unknown column 't0.email' in 'where clause'

Upvotes: 0

Views: 223

Answers (2)

Victor Moura
Victor Moura

Reputation: 124

Just for information, if you have an class inheritance like "UserSuper > GenericUserClass", class GenericUserClass should be a @MappedSuperClass instead of @Entity.

Upvotes: 2

AdrienBrault
AdrienBrault

Reputation: 7745

It's likely that you've not updated your database schema after you've added the email property.

If you're using symfony2, try to run

php app/console doctrine:schema:update --force

Upvotes: 0

Related Questions