ZF-6788: Bug in Zend_Db_Statement::fetchAll() causes Zend_Db_Adapter_Abstract::fetchCol() to return incomplete result if fetched column contains value of null or 0

Issue Type: Bug Created: 2009-05-23T11:46:15.000+0000 Last Updated: 2011-08-04T09:49:04.000+0000 Status: Resolved Fix version(s): - 1.8.3 (09/Jun/09)

Reporter: Mason Wolf (dooby) Assignee: Satoru Yoshida (satoruyoshida) Tags: - Zend_Db

Related issues: - ZF-2112



I used the function Zend_Db_Adapter_Abstract::fetchCol() to return all the values in a single column. When it called Zend_Db_Statement::fetchAll() the result set was incomplete. I traced the problem to this while loop (Zend/Db/Statement.php, starting around line 328):

<pre class="highlight">
            while ($val = $this->fetchColumn($col)) {
                $data[] = $val;

When the column value was null or 0, the while loop ended, even though it contained only a partial list of the values.

I fixed it on my local instance by making the following change:

<pre class="highlight">
            while (($val = $this->fetchColumn($col)) !== false) {
                $data[] = $val;

I leave it to you to decide if this is the best approach. Fixed it for me though. I'm using release 1.7.7.


Posted by old of Satoru Yoshida ( on 2009-05-29T07:25:50.000+0000

It duplicates ZF-2112

Have you found an issue?

See the Overview section for more details.


© 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.