开发者

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,

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜