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
Description
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):
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:
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.
Comments
Posted by old of Satoru Yoshida (yoshida@zend.co.jp) on 2009-05-29T07:25:50.000+0000
It duplicates ZF-2112