|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-08-18 05:42 UTC] sjaensch at gmx dot net
Description: ------------ DB::getAssoc() always returns results in DB_FETCHMODE_ORDERED, regardless of the mode set with DB:setFetchMode(). I manually have to call getAssoc($query, FALSE, array(), DB_FETCHMODE_ASSOC) to get column names as indexes. This is not consistent and not documented. Contrary to the documentation in http://pear.php.net/manual/en/package.database.db.db-common.getassoc.php, the default value for fetchmode is DB_FETCHMODE_ORDERED, as verified in DB/common.php shipped with PHP 4.3.2 (DB 1.1.3) and DB/common.php from DB 1.4.0. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 14 16:00:01 2025 UTC |
Here is a patch that should fix the issues. I need feedbacks... Index: DB/common.php =================================================================== RCS file: /repository/pear/DB/DB/common.php,v retrieving revision 1.22 diff -u -u -r1.22 common.php --- DB/common.php 22 Jul 2003 21:54:16 -0000 1.22 +++ DB/common.php 18 Aug 2003 11:20:54 -0000 @@ -1034,7 +1034,7 @@ */ function &getAssoc($query, $force_array = false, $params = array(), - $fetchmode = DB_FETCHMODE_ORDERED, $group = false) + $fetchmode = 'default', $group = false) { settype($params, "array"); if (sizeof($params) > 0) { @@ -1049,6 +1049,9 @@ } else { $res = $this->query($query); } + if ($fetchmode == 'default') { + $fetchmode = $this->fetchmode; + } if (DB::isError($res)) { return $res; Note: I also have a patch that fixes the oci8 problem #25067Thansk for the VERY quick reactions! But even after updating to the latest versions (some 7/4/2004), the problem continues. This is the code which worked correctly: $db->setFetchMode(DB_FETCHMODE_ASSOC) ; while ($qry->fetchInto($rowout)) { /*display the data */ but it works only if I put while ($qry->fetchInto($rowout,DB_FETCHMODE_ASSOC )) { /*display the data */ Putting as tracing in mysql.php before lin 287 in fucntion fetchInto : echo "mysql.php: fetchmode = $fetchmode; this fetchmode = ".$this->fetchmode."<br>\n"; if ($fetchmode & DB_FETCHMODE_ASSOC) { gives as result: mysql.php: fetchmode = 1; this fetchmode = 2 and I receive a numbered array instead of a associative array!This works fine for me: <?php $db->query('CREATE TABLE blah (a integer)'); $db->query('INSERT INTO blah VALUES (5)'); $res =& $db->query('SELECT a FROM blah'); $db->setFetchMode(DB_FETCHMODE_ASSOC); while ($res->fetchInto($row)) { print_r($row); } $db->query('DROP TABLE blah'); ?> Seems like you have a bug in your script.