Issues

ZF-3727: Clear limitoffset and limitcount parts in Dbselect adapter when getting the total items count

Description

Counting the total items for the select query returns null when select has limit and offset parts "Row count column not found" exception throwes

Comments

If you're trying to provide a custom count query, don't forget to add the zend_paginator_row_count column in the columns part of the query. There's a constant for this in the DbSelect adapter class. Also, the adapter adds the limit and offset parts automatically, so there's no need to do that yourself. I'm closing this as Not an Issue. Please provide some more details if you do think this is a bug :)

I think that the offset part is not needed in counting rows. Selecting rows count with offset part will always return null if offset is greater than 0 Ex: select count(*) from bugs LIMIT 10 OFFSET 30

Here are my actual examples:

This code throws the exception


           $bugsTable        = new Bugs();
            $bugsRowset    = $bugsTable->find(1234);
            $bug1234          = $bugsRowset->current();
            
            $productsTable = new Products();
            $productsRowset   = $bug1234->findManyToManyRowset('Products', 'BugsProducts', null, null, $select = $productsTable->select()->limitPage(2, 10));
            
            $paginator = Zend_Paginator::factory($select)->
                                    setCurrentPageNumber(2)
                                        ->setItemCountPerPage(10);

The code works fine after I clear the offset limit part of the select


            $bugsTable        = new Bugs();
            $bugsRowset       = $bugsTable->find(1234);
            $bug1234          = $bugsRowset->current();
            
            $productsTable = new Products();
            $productsRowset   = $bug1234->findManyToManyRowset('Products', 'BugsProducts', null, null, $select = $productsTable->select()->limitPage(2, 10));
            
            $paginator = Zend_Paginator::factory($select->reset(Zend_Db_Select::LIMIT_OFFSET))->
                                    setCurrentPageNumber(2)
                                        ->setItemCountPerPage(10);

Resolved in revision 10630