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

Closed
opened 2026-01-22 14:09:45 +01:00 by admin · 4 comments
Owner

Originally created by @doctrinebot on GitHub (Apr 11, 2013).

Originally assigned to: @Ocramius on GitHub.

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

Originally created by @doctrinebot on GitHub (Apr 11, 2013). Originally assigned to: @Ocramius on GitHub. 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');
admin added the New Feature label 2026-01-22 14:09:45 +01:00
admin closed this issue 2026-01-22 14:09:46 +01:00
Author
Owner

@doctrinebot commented on GitHub (Apr 11, 2013):

Comment created by @ocramius:

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

@doctrinebot commented on GitHub (Apr 11, 2013): Comment created by @ocramius: In strings, you always use the fully qualified class name, or an entity alias
Author
Owner

@doctrinebot commented on GitHub (Apr 11, 2013):

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 commented on GitHub (Apr 11, 2013): 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
Author
Owner

@doctrinebot commented on GitHub (Apr 11, 2013):

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 commented on GitHub (Apr 11, 2013): 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
Author
Owner

@doctrinebot commented on GitHub (Apr 11, 2013):

Issue was closed with resolution "Invalid"

@doctrinebot commented on GitHub (Apr 11, 2013): Issue was closed with resolution "Invalid"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#3011