DB::getAssoc doesn't use global fetchmode

From: Date: Thu, 05 Sep 2002 18:15:58 +0000
Subject: DB::getAssoc doesn't use global fetchmode
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-8854@lists.php.net to get a copy of this message
Setting the global fetchmode with the setFetchMode method has no effect on the getAssoc method. For example, given a table named users with the rows: id name email ---- ------------ --------------- jim James Smith jim@example.com bob Robert Brown bob@example.com tom Thomas Green tom@example.com and the following code: $res = $db->getAssoc("select id, name, email from users") you receive this result, as expected: $res = array( "jim" => array(0 => "James Smith", 1 => "jim@example.com"), "bob" => array(0 => "Robert Brown", 1 => "bob@example.com"), "tom" => array(0 => "Thomas Green", 1 => "tom@example.com") ); With this code: $res = $db->getAssoc("select id, name, email from users", false, null, DB_FETCHMODE_ASSOC) you receive this result, as expected: $res = array( "jim" => array("name" => "James Smith", "email" => "jim@example.com"), "bob" => array("name" => "Robert Brown", "email" => "bob@example.com"), "tom" => array("name" => "Thomas Green", "email" => "tom@example.com") ); I would think that this code: $db->setFetchMode(DB_FETCHMODE_ASSOC); $res = $db->getAssoc("select id, name, email from users"); should yeild the same result as in the second example where DB_FETCHMODE_ASSOC was passed explicitly, but it doesn't -- it gives the same result as the first example, as if you had specified DB_FETCHMODE_ORDERED. Is that correct? Thanks, -- Alex Howansky Wankwood Associates http://www.wankwood.com/

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