ZF-4094: Row count column not found Error

Issue Type: Bug Created: 2008-08-27T12:52:35.000+0000 Last Updated: 2008-10-10T19:26:42.000+0000 Status: Resolved Fix version(s): - 1.6.2 (13/Oct/08)

Reporter: Eric Hokanson (pceric) Assignee: Jurrien Stutterheim (norm2782) Tags: - Zend_Paginator

Related issues: - ZF-3809



Getting this regression in v1.6.0RC3 in Zend_Paginator with the DbSelect adapter. Works fine with previous 1.6.0RC versions.

Fatal error: Uncaught exception 'Zend_Paginator_Exception' with message 'Row count column not found' in /var/www/ZendFramework-1.6.0RC3/library/Zend/Paginator/Adapter/DbSelect.php:102 Stack trace: #0 /var/www/ZendFramework-1.6.0RC3/library/Zend/Paginator/Adapter/DbSelect.php(175): Zend_Paginator_Adapter_DbSelect->setRowCount(Object(Zend_Db_Select)) #1 /var/www/ZendFramework-1.6.0RC3/library/Zend/Paginator.php(702): Zend_Paginator_Adapter_DbSelect->count() #2 /var/www/ZendFramework-1.6.0RC3/library/Zend/Paginator.php(476): Zend_Paginator->_calculatePageCount() #3 /var/www/html/working/stones/index.php(73): Zend_Paginator->setItemCountPerPage(20) #4 {main} thrown in /var/www/ZendFramework-1.6.0RC3/library/Zend/Paginator/Adapter/DbSelect.php on line 102

Sample code:

<pre class="highlight">
    require_once 'Zend/Paginator.php';
    require_once 'Zend/Db.php';

    try {
        $db = Zend_Db::factory('Mysqli', array(
            'host'     => 'localhost',
            'username' => 'name',
            'password' => 'pass',
            'dbname'   => 'message_stones',
    } catch (Zend_Db_Adapter_Exception $e) {

    $select = $db->select()->from('messages', array('id', 'name', 'message_line_1', 'wall', 'wall_row', 'wall_column'))->where("message_line_1 = ?", 'Smith');
    $paginator = Zend_Paginator::factory($select);
    $view->paginator = $paginator;

UPDATE: Okay, I had some time to debug it a bit. It looks like the fix for ZF-4001 broke it (revision 10942). Your your trying to cast an Zend_Db_Expr Object to a string which is a no go. Some dirty looking code there, I'm not sure how it works for anyone. This fixes it:

<pre class="highlight">
--- ZendFramework-1.6.1/library/Zend/Paginator/Adapter/DbSelect.php     2008-08-22 15:01:20.000000000 -0600
+++ ZendFramework-1.6.1-Fixed/library/Zend/Paginator/Adapter/DbSelect.php       2008-09-18 01:35:04.000000000 -0600
@@ -92,8 +92,8 @@
         if ($rowCount instanceof Zend_Db_Select) {
             $columns = $rowCount->getPart(Zend_Db_Select::COLUMNS);
-            if (false === strpos((string) $columns[0][1], self::ROW_COUNT_COLUMN)) {
+            if (false === strpos($columns[0][1]->__toString(), self::ROW_COUNT_COLUMN)) {
                  * @see Zend_Paginator_Exception

Ah, the problem is a pre PHP 5.2.0 bug as stated in the PHP docs: {quote} It is worth noting that before PHP 5.2.0 the __toString method was only called when it was directly combined with echo() or print(). {quote}


Posted by Jurrien Stutterheim (norm2782) on 2008-08-31T04:11:01.000+0000

Could you provide some sample code?

Posted by Luke Visinoni (nozavroni) on 2008-09-09T15:18:17.000+0000

I'm having this same issue. In RC2 I had to specify the from() in the select even if the select came from Zend_Db_Table, then in the final 1.6 release, it throws this exception.

Posted by Jurrien Stutterheim (norm2782) on 2008-09-13T02:48:46.000+0000

I seem to be unable to reproduce this issue. Luke, could you perhaps provide some sample code as well?

Posted by Jurrien Stutterheim (norm2782) on 2008-09-18T00:26:07.000+0000

Hmm... I must've overlooked the fact that it's a Zend_Db_Expr. Still, casting to a string should call __toString just the same. Anyway, thanks for this. I'll have a look at a fix in about an hour from posting this comment :)

Posted by Jurrien Stutterheim (norm2782) on 2008-09-18T05:57:14.000+0000

Resolved in revision 11426

Have you found an issue?

See the Overview section for more details.


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

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