Re: DB::getAssoc doesn't use global fetchmode

From: Date: Thu, 05 Sep 2002 20:18:08 +0000
Subject: Re: DB::getAssoc doesn't use global fetchmode
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-8858@lists.php.net to get a copy of this message
On Thu Sep 05, 2002 at 01:1558PM -0500, Alex Howansky wrote: > Setting the global fetchmode with the setFetchMode method has no effect on the > getAssoc method. > 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? Yes, it is in fact correct. If you don't pass a value for the 4th parameter to the method, it will take DB_FETCHMODE_ORDERED as the default value, which leads to the result you've experienced. A solution to this problem might be to use DB_FETCHMODE_DEFAULT as the default value for the parameter. In this case the fetchmode that has been defined via setFetchMode() will be used. But actually I'm a bit afraid that this will break a number of existing scripts. -- - Martin Martin Jansen http://martinjansen.com/

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