Zend Framework

Clear limitoffset and limitcount parts in Dbselect adapter when getting the total items count

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.6.0RC1
  • Fix Version/s: 1.6.0
  • Component/s: Zend_Paginator
  • Labels:
    None

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

Activity

Hide
Jurrien Stutterheim added a comment -

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

Show
Jurrien Stutterheim added a comment - 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
Hide
Stanislav Anisimov added a comment -

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);
Show
Stanislav Anisimov added a comment - 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);
Hide
Jurrien Stutterheim added a comment -

Resolved in revision 10630

Show
Jurrien Stutterheim added a comment - Resolved in revision 10630

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: