Re: getAssoc

From: Date: Tue, 25 Apr 2000 17:56:21 +0000
Subject: Re: getAssoc
References: 1  Groups: php.pear 
Request: Send a blank email to php-pear+get-77@lists.php.net to get a copy of this message
Sterling Hughes wrote: > > I was just going through DB/common.php, and when looking at getAssoc I > realized there was a problem... > > getAssoc returns an associative array where the first column of the row > is the index and all of the other columns for that row are an array > which is the corresponding value for the first column, something like: > > array( > 'firstcolumn' => array('secondcolumn' ...) > ) > > While this may work if the table you are performing a query on as a > unique key as the first column, it won't work were a unique key is not > the first column. If the firstcolumn on two rows have duplicate values, > then data gets lost... > > Below are the diffs which will change the structure of the array to the > following: > > array( > array('firstcolumn', 'secondcolumn') > ) As the name "getAssoc" implies, this method is meant to build an associative array of the result data, and thus it doesn't make sense to use it for queries where the first column is not unique. getAll() is supposed to return data in the format you describe. I haven't been able to spend any time with PHP for "personal reasons" the last month, so that is why getAll() hasn't made it further. :-) - Stig

« previous php.pear (#77) next »