开发者

What are the entities namespaces and alias in Doctrine2?

开发者 https://www.devze.com 2023-02-15 14:33 出处:网络
In the documentation I saw this method: addEntityNamespace($alias, $namespace); B开发者_运维技巧ut I can\'t find anywhere what is it about.

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,

0

精彩评论

暂无评论...
验证码 换一张
取 消