Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2398

Add a "use namespace" like feature to DQL to have short/reusable entity classname

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Invalid
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: DQL

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

        Activity

        David Berlioz created issue -
        Hide
        Marco Pivetta added a comment -

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

        Show
        Marco Pivetta added a comment - In strings, you always use the fully qualified class name, or an entity alias
        Hide
        David Berlioz added a comment -

        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

        Show
        David Berlioz added a comment - 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
        Hide
        Marco Pivetta added a comment -

        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

        Show
        Marco Pivetta added a comment - 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
        Marco Pivetta made changes -
        Field Original Value New Value
        Status Open [ 1 ] Closed [ 6 ]
        Assignee Benjamin Eberlei [ beberlei ] Marco Pivetta [ ocramius ]
        Resolution Invalid [ 6 ]

        This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

        • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DDC-2398, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

          • Assignee:
            Marco Pivetta
            Reporter:
            David Berlioz
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: