Re: Porting Code to Postgresql - Mailing list pgsql-general

From scott.marlowe
Subject Re: Porting Code to Postgresql
Date
Msg-id Pine.LNX.4.33.0310151606460.24429-100000@css120.ihs.com
Whole thread Raw
In response to Re: Porting Code to Postgresql  (Dennis Gearon <gearond@fireserve.net>)
List 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);
    ...
}



pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Getting error codes for failed queries?
Next
From: Peter Eisentraut
Date:
Subject: Re: Getting error codes for failed queries?