So I have 3 entities within one table. I need to be able to search 2 out of the 3 entities in one select statement, but I'm not sure how to do this.
标签:
doctrine-orm
相关问题
- Lifecycle Callback Issue When Extending FOSUserBun
- Doctrine 2.5: Unrecognized field (but only in Symf
- Doctrine return null in place of EntityNotFoundExc
- two many2many self-referencing collection
- Doctrine inheritance for entities common fields
相关文章
- Symfony : Doctrine data fixture : how to handle la
- Is there a way to modify the entity mapping config
- Get random records with Doctrine
- Doctrine not finding data on Google App Engine?
- Doctrine 2: Cannot select entity through identific
- Symfony does not remove entity from collection
- Symfony doctrine:schema:update not working
- Storing Doctrine2 DateTime in UTC Only
Use the
INSTANCE OF
operator in your dql query like this (whereUser
is your base class):Doctrine translates this in the sql query in a
WHERE user.type = '...'
condition.See here for more details on the dql query syntax.
As commented by flu, if you want to retrieve some entities from different instances with a QueryBuilder instead of a DQL query, you can use an array as parameter:
The answer for multiple instances actually doesn't work. You would have to do something like this to check for multiple instances.