Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0-ALPHA2
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None

      Description

      Currently (2.0 Alpha 1) QueryBuilder does not support limit or offset functionality. These were supported in Doctrine 1 and should be added. QueryBuilder's value is significantly lower without these features because simple pagination is not possible. Methods limit($limit) and offset($offset) should be added to QueryBuilder, like in Doctrine 1. Query already has support for limit and offset, so this should not be a large change.

        Activity

        Hide
        Roman S. Borschel added a comment -

        You can set the limit/offset on the query when you're done building it.

        $qb = $em->createQueryBuilder();
        //.. build your query
        $q = $qb->getQuery();
        $q->setFirstResult($offset);
        $q->setMaxResults($limit);
        $result = $q->getResult();
        

        LIMIT/OFFSET is no longer part of DQL.

        We may consider adding forwarding methods to QueryBuilder, similar to setParameter() but only if there is some advantage to it. Is there?

        Show
        Roman S. Borschel added a comment - You can set the limit/offset on the query when you're done building it. $qb = $em->createQueryBuilder(); //.. build your query $q = $qb->getQuery(); $q->setFirstResult($offset); $q->setMaxResults($limit); $result = $q->getResult(); LIMIT/OFFSET is no longer part of DQL. We may consider adding forwarding methods to QueryBuilder, similar to setParameter() but only if there is some advantage to it. Is there?
        Hide
        Guilherme Blanco added a comment -

        Although it's currently possible to be done via Query retrieval, I think Ismo is correct and we should add 2 delegate methods to setFirstResult and setMaxResults.
        That would make QueryBuilder more complete and easy to follow the workflow (Query <=> QueryBuilder).

        I'm +1 to add it. If you agree, I can implement the patch and attach to next release.

        Show
        Guilherme Blanco added a comment - Although it's currently possible to be done via Query retrieval, I think Ismo is correct and we should add 2 delegate methods to setFirstResult and setMaxResults. That would make QueryBuilder more complete and easy to follow the workflow (Query <=> QueryBuilder). I'm +1 to add it. If you agree, I can implement the patch and attach to next release.
        Hide
        Guilherme Blanco added a comment -

        I found this enhancement interesting and implemented this. I committed a patch to support it in trunk, so in next alpha it'll be available.

        Changeset: http://trac.doctrine-project.org/changeset/6415

        Cheers,

        Show
        Guilherme Blanco added a comment - I found this enhancement interesting and implemented this. I committed a patch to support it in trunk, so in next alpha it'll be available. Changeset: http://trac.doctrine-project.org/changeset/6415 Cheers,

          People

          • Assignee:
            Guilherme Blanco
            Reporter:
            Ismo Toijala
          • Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: