Re: PostgreSQL driver and internal row counting

From: Date: Sun, 07 Oct 2001 13:09:31 +0000
Subject: Re: PostgreSQL driver and internal row counting
References: 1 2  Groups: php.dev 
Request: Send a blank email to php-dev+get-67475@lists.php.net to get a copy of this message
Hi, I wrote this patch, but still did not update the documentation. I have no idea how to do this - but if anybody sends me the files to update & modify, I'll do this asap. Yes, the patch was fully backward compatible, but also allows one to use PostgreSQL like mysql or other database drivers and keep the code much shorter and more efficient. Cheers, Georg On Sun, Oct 07, 2001 at 10:00:38PM +1000, Gavin Sherry wrote: > On Sun, 7 Oct 2001, Sebastian Bergmann wrote: > > > This patch > > > > > > http://cvs.php.net/diff.php/php4/ext/pgsql/pgsql.c?r1=1.111&r2=1.112&f=u > > > > allowed the PostgreSQL driver to do internal row counting when > > iterating through a result set. But how do I use it? I still do > > something like > > > > pg_fetch_array($result, $row++, PGSQL_ASSOC) > > > > and manually count the rows. I'd test it, but I currently have no > > PostgreSQL installation at my avail. > > I had a play with this patch because I am giving a total break down of > Postgres at the 2001 PHP Conference. > > pg_fetch_array(), pg_fetch_row(), pg_fetch_object() and pg_result are all > affected by this patch. They now have the following form: > > array pg_fetch_row(int result [, int row]) > object pg_fetch_object(int result [, int row [, int result_type]]) > array pg_fetch_array(int result [,int row [, int result_type]]) > mixed pg_result(int result [, int row], mixed fieldname) > > > If this is the first call to either function and 'row' is not given, the > internal row counter is set to zero. Otherwise, in the case of the first > three, the row is returned and the row counter is incremented by one. In > the case of pg_result(), the result for 'fieldname' at the row pointed to > by the row point is returned. > > If the value of the internal row counter > number of rows returned, the > functions return false. > > For pg_fetch_(array|object)(), if 'row' is omitted, 'result_type' must > also be omitted - PGSQL_BOTH is assumed. Naturally, if you make the > mistake of doing something like: > > $row = pg_fetch_array($res,PGSQL_ASSOC); > > $row will be the result of 2nd row (PGSQL_ASSOC == 1). > > Gavin > > > -- > PHP Development Mailing List <http://www.php.net/> > To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net > For additional commands, e-mail: php-dev-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.dev (#67475) next »