What are the entities namespaces and alias in Doctrine2?
In the documentation I saw this method:
addEntityNamespace($alias, $namespace);
B开发者_运维技巧ut I can't find anywhere what is it about.
Any ideas?
Entity namespaces are a shortcut to aliasing Entities when pointing to other classes. A good example of an entity namespace is inside DQL queries.
When you define a namespace, like: ->addEntityNamespace('app', 'Application\Entity'); You can then refer to them easily. In a DQL sample, instead of write this:
SELECT u FROM Application\Entity\User u
You can do that:
SELECT u FROM app:User u
I hope this helps. =)
Cheers,
精彩评论