Bug #11437 Updated: PEAR: DB_common::getAssoc doesn't work correctly with DB_FETCHMODE_ASSOC

From: Date: Thu, 14 Jun 2001 21:01:51 +0000
Subject: Bug #11437 Updated: PEAR: DB_common::getAssoc doesn't work correctly with DB_FETCHMODE_ASSOC
Groups: php.dev 
Request: Send a blank email to php-dev+get-56965@lists.php.net to get a copy of this message
ID: 11437 Updated by: sniper Reported By: marcel@anacker.com Old-Status: Open Status: Bogus Old-Bug Type: Unknown/Other Function Bug Type: *General Issues Operating system: PHP Version: 4.0.5 Assigned To: Comments: This bug system is for reporting bugs in PHP the language, not anything that has done using it. Report these bugs to ssb@php.net Previous Comments: --------------------------------------------------------------------------- [2001-06-12 11:04:15] marcel@anacker.com a snippet from DB_common::getAssoc (PEAR/php/DB/common.php): if ($cols > 2 || $force_array) { // return array values // XXX this part can be optimized while (($row = $this->fetchRow($res, DB_FETCHMODE_ORDERED)) && !DB::isError($row)) { reset($row); // we copy the row of data into a new array // to get indices running from 0 again $results[$row[0]] = array_slice($row, 1); } } else { // return scalar values while (($row = $this->fetchRow($res)) && !DB::isError($row)) { $results[$row[0]] = $row[1]; } } In the if branch fetchRow is called with "DB_FETCHMODE_ORDERED" to ensure the result is indexed by numbers, in the else branch it isn't. I have set the default fetchmode to DB_FETCHMODE_ASSOC and so this function (called with a query with 2 columns) won't work for me unless I call "$DB->setFetchmode(DB_FETCHMODE_ORDERED)" before. Conclusion: "$this->fetchRow($res))" should be changed to "$this->fetchRow($res,DB_FETCHMODE_ORDERED))" --------------------------------------------------------------------------- ATTENTION! Do NOT reply to this email! To reply, use the web interface found at http://bugs.php.net/?id=11437&edit=2

« previous php.dev (#56965) next »