Skip site navigation (1) Skip section navigation (2)

Re: Best WebInterface...?

From: Robert McGinnis <fprefect(at)elite(dot)net>
To: Alfred Perlstein <bright(at)wintelcom(dot)net>
Cc: Herb Pabst <herbie(at)nextearth(dot)com>, pgsql-list <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Best WebInterface...?
Date: 2001-01-30 15:37:59
Message-ID: Pine.LNX.4.30.0101300721270.17695-100000@localhost (view raw or flat)
Thread:
Lists: pgsql-novice
On Mon, 29 Jan 2001, Alfred Perlstein wrote:

> Date: Mon, 29 Jan 2001 14:13:38 -0800
> From: Alfred Perlstein <bright(at)wintelcom(dot)net>
> To: Herb Pabst <herbie(at)nextearth(dot)com>
> Cc: pgsql-list <pgsql-novice(at)postgresql(dot)org>
> Subject: Re: Best WebInterface...?
>
> * Herb Pabst <herbie(at)nextearth(dot)com> [010129 14:00] wrote:
> > I'm think of using PHP with Postgresql. Are there
> > any limitations to PHP that will keep me from
> > using PGsql to it fullest? Any recommendations?
>
> I'm not sure if this is true, but I think php doesn't support
> cursors, so large queiries may have to be sucked into the
> webserver instead of processed one row at a time.
>
>
I have used cursors with php for over a year.  The problem is that is does
not support them natively; any code that tests the call for pg_exec may
fail since the return is undefined.  Here's how I write the code:
//Note this is off the top of my head, you code may vary :-)

$q = "begin";
$count = "select count (*) from clients where active='t'";
$qry =  "declare fred cursor for select * from clients where active='t';
$fetch = "fetch 20 from fred";
$fini = "commit";
if(! $res1 = pg_exec( $connect, $count ) ){
	return 0;
}
if ( 0 < pg_numrows( $res1 ) ){
	pg_exec( $connect, $q );       //undefined behavior
	pg_exec( $connect, $qry );     //undefined behavior
	if (! $res= pg_exec( $connect, $q ) ){
		return 0;
	}
	pg_exec($connect, $fini);       //undefined bevhavior
	if ( 0 >= pg_numrows( $res ) ){
		return 0;
	}
	do_something ( $res )
}
pg_free_result( $res );
pg_free_result( $res1);

Move forward and backward works as before the fetch.  The part that I
don't like is the inability to check whether the transaction block querys
work; I had to console myself with counting the number of results I should
get for the same query.  The bad part is that there is WAY to many queries
being executed; the good part is it save a great many lines of
quasi-convoluted logic whilst incrementing to the n or n+1 row of an
answer.  I hope this helps,
--+*==#==*+----+*==#==*+----+*==#==*+----+*==#==*+----+*==#==*+----+*==#==*+--
fprefect(at)dustpuppy(dot)net                         Currently doing fieldwork as:
Elite.net Support                              Robert McGinnis
"So an object class contains the data, plus everything the class can do.
But is it a direct object, indirect object, or object of a preposition?"6/7/97


In response to

Responses

pgsql-novice by date

Next:From: Francisco ReyesDate: 2001-01-30 15:56:33
Subject: Re: When replication?
Previous:From: pejacDate: 2001-01-30 15:24:50
Subject: re : Slow date comparison

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group