Re: fetchAll() for DB classes

From: Date: Wed, 28 Nov 2001 00:26:36 +0000
Subject: Re: fetchAll() for DB classes
References: 1 2 3 4  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-3141@lists.php.net to get a copy of this message
"Tomas V.V.Cox" <cox@idecnet.com> wrote in message news:3C042D61.98110B99@idecnet.com... > "André Næss" wrote: > > > > "Richard Heyes" <richard@phpguru.org> wrote in message > > news:NEBBIDEMHHJJCANAAAKFMEKDJOAA.richard@phpguru.org... > > > > Maybe I'm missing something obvious, but how is that different from the > > > > existing getAll() ? > > > > > > It's not. I missed that one. > > > > Actually, one thing I frequently do when working with resultsets is the same > > as fetchAll() but with a specified key, typically an id field. So would it > > be possible to have a fetchAll($keyfield) function? Of course, the user > > would be responsible for the uniqueness of the key field... An example: > > > > Take a look at the getAssoc() method. FYI: there is also getOne(), > getRow(), getCol(), apart from the mentioned getAssoc() and getAll(). Hm... I find the name a bit misleading because the data are just in a standard array. Also, I would prefer to have each key point to an entire row, this might seem redundant, but I frequently need to access the id for a given row, and it's quite handy to have it in there. Look at my example again, and see how the data are also stored in an assoc array, which IMHO is what you should expect from a method called getAssoc()... (Especially considering the *_fetch_assoc() methods...) André Næss

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