Re: Re: [PHP-PEAR] getAssoc

From: Date: Tue, 25 Apr 2000 18:46:08 +0000
Subject: Re: Re: [PHP-PEAR] getAssoc
Groups: php.pear 
Request: Send a blank email to php-pear+get-78@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 Yup, I saw that a little after I wrote the message, that's why I didn't bother commiting the patch... I can write the getAll() function, it seems simple enough. Sterling

« previous php.pear (#78) next »