Doctrine 1
  1. Doctrine 1
  2. DC-739

Pager returns incorrect page number when constructed on query with HAVING

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.2
    • Fix Version/s: None
    • Component/s: Pager
    • Labels:
      None
    • Environment:
      Ubuntu 9.10,
      Apache/MySQL,
      Framework: Symfony 1.4

      Description

      //method returns those categories that have any products, it returns 3 records
      public function getCategoriesWithProductsQuery()

      { $query = $this->createQuery('z')->select( 'z.*, COUNT(p.id) prod_number' ) ->leftJoin( 'z.AdvertiseProducts p' )->groupBy( 'z.id' )->having('prod_number > 0'); return $query; }

      //but when i do count() on created pager it returns 8 records (which is equal to categories in my database):

      $doctrinePager = $this->getServiceContainer()
      ->setParameter('doctrine_pager.model', 'ZwCategory')
      ->getService('doctrine_pager')
      >setMaxPerPage($this>maxPerPage)
      ->setQuery($query)
      >setPage(null === $page ? $this>page : $page)
      ->init();
      var_dump(count($doctrinePager));

      //pager works, but it "thinks" that there are more pages than in reality. with maxPerPage = 2, it thinks that there are 4 pages, but looking at query result it //should be only 2 pages.

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Guilherme Blanco
            Reporter:
            Paweł Barański
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: