Issues

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

Issue Type: Bug Created: 2008-07-23T13:25:24.000+0000 Last Updated: 2008-10-10T19:23:28.000+0000 Status: Resolved Fix version(s): - 1.6.0 (02/Sep/08)

Reporter: Stanislav Anisimov (satanistlav) Assignee: Matthew Ratzloff (mratzloff) Tags: - Zend_Paginator

Related issues: Attachments:

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

Posted by Jurrien Stutterheim (norm2782) on 2008-07-23T13:36:24.000+0000

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 :)

Posted by Stanislav Anisimov (satanistlav) on 2008-07-23T14:15:56.000+0000

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

<pre class="highlight">
           $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

<pre class="highlight">
            $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);

Posted by Jurrien Stutterheim (norm2782) on 2008-08-04T07:41:10.000+0000

Resolved in revision 10630

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts