Thread: PHP3 and PostgreSQL
SORRY, WRONG SUBJECT IN PREVIOUS MESSAGE. Hi all, I'm trying to do the equivalent of the following command of mysql (inside PHP3 code) in postgreSQL. while (($row = mysql_fetch_object($result))) ..... I know there is the pg_fetch_object($result, ?) but I don't know what to use for ?. I tried 0 and it does an exhaustive search. I tried using something like $num $num=0 while (($row = mysql_fetch_object($result,$num))) ... $num++; this is the error message I get : Warning: Unable to jump to row 1 on PostgresSQL result index 2 Any ideas ? thanks, -Sheila ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com
Try something like: $NumRows = pg_NumRows($Result); for ($CurRow =0; $CurRow < $NumRows; $CurRow++) { $row = pg_Fetch_Object($Result, $CurRow); .... } I've never used Fetch_Object, but I know that this works with Fetch_Array. Also, if you consult the pg_Fetch_Object item in the quick reference on http://www.php.net/ it will probably have a code example. At 04:29 PM 2/20/00, sheila bel wrote: >SORRY, WRONG SUBJECT IN PREVIOUS MESSAGE. > >Hi all, > >I'm trying to do the equivalent of the following command of >mysql (inside PHP3 code) in postgreSQL. > >while (($row = mysql_fetch_object($result))) ..... > >I know there is the pg_fetch_object($result, ?) but I don't >know what to use for ?. I tried 0 and it does an exhaustive >search. I tried using something like $num > >$num=0 >while (($row = mysql_fetch_object($result,$num))) ... > >$num++; > >this is the error message I get : > >Warning: Unable to jump to row 1 on PostgresSQL result index 2 > >Any ideas ? > >thanks, >-Sheila >______________________________________________________ >Get Your Private, Free Email at http://www.hotmail.com > > >************
On Sun, 20 Feb 2000, sheila bel wrote: > I'm trying to do the equivalent of the following command of > mysql (inside PHP3 code) in postgreSQL. Oh I see there can help only Oliver Elphick or Paul DuBois. > while (($row = mysql_fetch_object($result))) ..... > > I know there is the pg_fetch_object($result, ?) but I don't > know what to use for ?. I tried 0 and it does an exhaustive > search. I tried using something like $num The function prototype looks right now like: /* {{{ proto object pg_fetch_object(int result, int row) Fetch a row as an object */ > $num=0 > while (($row = mysql_fetch_object($result,$num))) ... > > $num++; While the function prototype in MySQL looks: /* {{{ proto object mysql_fetch_object(int result [, int result_typ]) Fetch a result row as an object */ The optional result_typ is a constant and can be set to MYSQL_ASSOC, MYSQL_NUM, or MYSQL_BOTH. > this is the error message I get : > > Warning: Unable to jump to row 1 on PostgresSQL result index 2 This means, you don't have a second row numbered 1 in result index 2. -Egon PS: If this is misleading, I should read the PHP documentation myself a couple of times. -- Besuchen Sie Six auf der CeBIT (24.2.-1.3.) in Halle 10, Stand 425, und auf der Hannover-Messe (20.-25.3.) in Halle 14, Stand J50!