Re: Porting Code to Postgresql

From: "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com>
To: Dennis Gearon <gearond(at)fireserve(dot)net>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Porting Code to Postgresql
Date: 2003-10-15 22:07:33
Message-ID: Pine.LNX.4.33.0310151606460.24429-100000@css120.ihs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, 15 Oct 2003, Dennis Gearon wrote:

>
> >$count = pg_numrows( $result);
> >for( $i = 0; $i < $count; $i++){
> > $row = pg_fetch_object( $result, $row);
> > ...
> >}
> >
> >if you want it to work.
> >
> >
> >
> in case of no rows, maybe do:
>
> $count = pg_numrows( $result);
> while ( 0 < $result ){
> $result--;
> $row = pg_fetch_object( $result, $row);
> ...
> }

But you don't want to decrement $result, it's a result handle, you want to
decrement count:

$count = pg_numrows( $result);
while ( 0 < $count ){
$count--;
$row = pg_fetch_object( $result, $row);
...
}

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Peter Eisentraut 2003-10-15 22:36:48 Re: Getting error codes for failed queries?
Previous Message Tom Lane 2003-10-15 20:57:44 Re: Getting error codes for failed queries?