[DDC-2398] Add a "use namespace" like feature to DQL to have short/reusable entity classname Created: 11/Apr/13  Updated: 11/Apr/13  Resolved: 11/Apr/13

Status: Closed
Project: Doctrine 2 - ORM
Component/s: DQL
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Minor
Reporter: David Berlioz Assignee: Marco Pivetta
Resolution: Invalid Votes: 0
Labels: Namespace, portability


I find not always portable-friendly the use of full class path in DQL.

$query = $em->createQuery('SELECT u FROM \MyProject\Model\User u WHERE u.age > 20');

could be :

$query = $em->createQuery('USE \MyProject\Model SELECT u FROM User u WHERE u.age > 20');

or :

$query = $em->use('\MyProject\Model')->createQuery('SELECT u FROM User u WHERE u.age > 20');

And with a default namespace attached to the entity manager :

$query = $em->use()->createQuery('SELECT u FROM User u WHERE u.age > 20');

Comment by Marco Pivetta [ 11/Apr/13 ]

In strings, you always use the fully qualified class name, or an entity alias

Comment by David Berlioz [ 11/Apr/13 ]

yes and so it's not symmetrical with PHP coding...
it's unesthetic and when you do code refactoring it's harder than just managing your use "namespace";
but i've put priority to minor ;p

Comment by Marco Pivetta [ 11/Apr/13 ]

David Berlioz I'm closing this. Strings are values passed around in your system, and having their meaning depend on context is absolutely a no-go

Generated at Tue Dec 01 04:34:53 EST 2015 using JIRA 6.4.10#64025-sha1:5b8b74079161cd76a20ab66dda52747ee6701bd6.