From:             [EMAIL PROTECTED]
Operating system: 
PHP version:      4.0.5
PHP Bug Type:     Unknown/Other Function
Bug description:  PEAR: DB_common::getAssoc doesn't work correctly with 

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)) {
        // 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 

Edit Bug report at:

PHP Development Mailing List <>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to