Re: fetchAll() for DB classes

From: Date: Wed, 28 Nov 2001 02:11:14 +0000
Subject: Re: fetchAll() for DB classes
References: 1 2 3 4 5  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-3143@lists.php.net to get a copy of this message
"André Næss" wrote: > > "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...) > Umm, well what you propose IMO is more a task of getAssoc() than getAll(). If I would have to choose my idea will be to add two extra params to getAssoc() specifying the fetchmode and the index col, because getAssoc() was done to return a result column as the key. That change would also enhance the actual status as the people would be able to select the index col instead of having to use only the first. Tomas V.V.Cox

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