[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


 Description   

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');



 Comments   
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 Fri Oct 24 08:26:04 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.