Issues

ZF-10884: Zend_Paginator - Row count column not found

Issue Type: Bug Created: 2010-12-30T04:38:29.000+0000 Last Updated: 2011-01-22T08:15:27.000+0000 Status: Resolved Fix version(s): - 1.11.3 (01/Feb/11)

Reporter: Marcin Wójcik (zeulus) Assignee: Ramon Henrique Ornelas (ramon) Tags: - Zend_Paginator

Related issues: Attachments:

Description

When using custom $rowCount as shown on example in manual:

<pre class="highlight">
$row_count->from(
  array('table_name'),
  array(
    Zend_Paginator_Adapter_DbSelect::ROW_COUNT_COLUMN => new Zend_Db_Expr('COUNT(DISTINCT id)')
  )
);

it throws 'Row count column not found' exception, because there is wrong checking for ROW_COUNT_COLUMN when using 'AS_field' => 'db_expr'. Current assigment:

<pre class="highlight">
$columns = $rowCount->getPart(Zend_Db_Select::COLUMNS);
$countColumnPart = $columns[0][1];

is not aware of 'AS' part, which is stored in $columns[0][2], and throws exception.

Possible solution is to check whether $columns[0][2] field is present or not, and use it as $countColumnPart when it's present.

Comments

Posted by Marcin Wójcik (zeulus) on 2010-12-30T04:45:11.000+0000

My patch for that problem:

<pre class="literal">
Index: library/Zend/Paginator/Adapter/DbSelect.php
===================================================================
--- library/Zend/Paginator/Adapter/DbSelect.php (revision 23595)
+++ library/Zend/Paginator/Adapter/DbSelect.php (working copy)
@@ -100,7 +100,7 @@
         if ($rowCount instanceof Zend_Db_Select) {
             $columns = $rowCount->getPart(Zend_Db_Select::COLUMNS);
 
-            $countColumnPart = $columns[0][1];
+            $countColumnPart = empty($columns[0][2]) ? $columns[0][1] : $columns[0][2];
 
             if ($countColumnPart instanceof Zend_Db_Expr) {
                 $countColumnPart = $countColumnPart->__toString();

Posted by Ramon Henrique Ornelas (ramon) on 2011-01-22T08:15:27.000+0000

Fixed in trunk r23658 merged to release branch 1.11 r23659 - thanks.

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