#25126 [Csd]: DB::getAssoc() does not use default fetch mode

From: Date: Mon, 19 Apr 2004 16:37:07 +0000
Subject: #25126 [Csd]: DB::getAssoc() does not use default fetch mode
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-28061@lists.php.net to get a copy of this message
ID: 25126 Updated by: danielc@php.net Reported By: sjaensch at gmx dot net Status: Closed Bug Type: PEAR related Operating System: Linux PHP Version: 4.3.2 Assigned To: cox New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2004-04-19 18:24:09] hubert dot christiaen at pandora dot be Thansk 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! ------------------------------------------------------------------------ [2004-04-19 17:55:42] danielc@php.net The versions of the files you're using are dated 2003/06/20 and 2003/06/21. The bug was fixed on 2003/08/28. So, of course it's not fixed in the version you're using. There have been significant fixes and enhancements to DB since then. The current version is 1.6.2. Update your installation. ------------------------------------------------------------------------ [2004-04-19 17:53:43] cipri@php.net > $Id: common.php,v 1.21 2003/06/20 20:41:30 cox Exp $ > $Id: mysql.php,v 1.19 2003/06/21 16:45:26 cox Exp $ Those seem to be quite old files. mysql.php is currently at 1.71, in the DB-1.6.2 package. You should try running "pear upgrade DB" to install the latest version of the PEAR::DB package, and see if that helps. While you're at it, you might like to update the rest of PEAR aswell (running "pear upgrade-all" will do that), since the PEAR shipped with your SUSE seems to be quite outdated :) ------------------------------------------------------------------------ [2004-04-19 17:42:10] Hubert dot Christiaen at pandora dot be This problem is not solved. I had code using the setFetchMode(DB_FETCHMODE_ASSOC) in a previous version (2001, $Id: DB.php,v 1.73.2.2 2001/11/13 01:26:39 and $Id: mysql.php,v 1.69.2.3 2001/11/13 01:26:42 ) and it worked correctly. Now in the version shipped with SuSE Linux 9.0 (version from 6/2004: $Id: common.php,v 1.21 2003/06/20 20:41:30 cox Exp $ and: $Id: mysql.php,v 1.19 2003/06/21 16:45:26 cox Exp $ it does not work correctly. Putting some tracing in mysql.php I found that $this->fetchmode == 2 (which is correct) but that $fetchmode == 1 (which is the default DB_FETCHMODE_ORDERED). So it seems that setFetchMode works correctly but that the new value is not passed to the method at execution time. ------------------------------------------------------------------------ [2003-08-28 09:31:21] cox@php.net This bug has been fixed in CVS. In case this was a PHP problem, snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. In case this was a documentation problem, the fix will show up soon at http://www.php.net/manual/. In case this was a PHP.net website problem, the change will show up on the PHP.net site and on the mirror sites in short time. Thank you for the report, and for helping us make PHP better. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/25126 -- Edit this bug report at http://bugs.php.net/?id=25126&edit=1

« previous php.pear.dev (#28061) next »