DDC-2398: Add a "use namespace" like feature to DQL to have short/reusable entity classname #3107

Closed
doctrinebot opened this Issue Apr 11, 2013 · 4 comments

2 participants

@doctrinebot

Jira issue originally created by user quazardous:

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

@doctrinebot

Comment created by @ocramius:

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

@doctrinebot

Comment created by quazardous:

yes :p 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

@doctrinebot

Comment created by @ocramius:

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

@doctrinebot

Issue was closed with resolution "Invalid"

@Ocramius Ocramius was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment