Doctrine Query Class Not in Entity Directory

2019-05-29 04:54发布

问题:

My Entity directory for my bundle is getting quite large. I'd like to be able to group my classes into sub-directories. For example, all forum related classes in Entity/Forum/. I've been able to do this relatively successfully, but I don't know how to do a doctrine query now.

The following doesn't work.

SELECT fp
FROM AcmeMainBundle:ForumPost fp
WHERE 1

How do I query an entity not directly in the Entity Folder?

回答1:

SELECT fp
FROM AcmeMainBundle:Forum\ForumPost fp
WHERE 1

This will work as long as you have changed the namespace of the entities you are moving to a seperate folder, for example Acme\MainBundle\Entity\Forum\ForumPost