Thanks; in fact I've tryed the second solution and it works for me; but I
can't understand why the script stop working during the upgrade of system.
The most strange thing is that, after a deeper investigation on the code,
I've found the PHP engine does something like closing the connection after
the second pg_exec command.
In fact, by using persistent connections I've partially corrected the
problem and the codes doesn't complain about using an invalid (but not null)
connection descriptor;  but it stills be unable to get results from
successive queries, also if result index are valid ! This sounds very
strange for me.

Thank you for your help !

Luca Lazzeroni

"Nuno Silva" <[EMAIL PROTECTED]> ha scritto nel messaggio
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hello,
>
> if the second query loops inside a _for_ statement and needs values from
> the first query you have two options:
>
> 1. save all the results from query one to some array and then loop
> inside the array within the _for_ statement executing new sql;
> 2. open two separate connections to the database and work with the two.
> like this:
> $conn1 = pg_connect(...);
> $conn2 = pg_connect(...);
> ...
> qry1 = pg_exec($conn1, $sql1);
> ...
> for ($i=.....) {
> ...
> $qry2 = pg_exec($conn2, $sql2);
> ...
> }
>
> Hope this helps,
> Nuno Silva
>
>
> Luca Lazzeroni wrote:
>
> > Hi,
> > I've recently migrated a system with PHP 4.0.3pl1 and PostgreSQL 7.0.2 -
> > RedHat Linux 5.1 (yes 5) to a new one with PHP 4.0.4pl1 - PostgreSQL
7.0.2 -
> > RedHat Linux 7.0.
> >
> > All my database applications work fine except one which does strange
things:
> > this is a piece of code:
> >
> > ----8<------- CUT ----
> >
> >    $conn = pg_connect("dbname=aaaa user=yyyyy password=xxxxxx");
> >
> >    $sql = "select * from table_a where condition_a";
> >    $qry1 = pg_exec ($conn,$sql);
> >
> >    $obj1 = pg_fetchobject($qry1,0);
> >
> >   // Until here everything works fine
> >
> >    $sql2 = "select * from table_b where condition_b=".$obj1->value_a;
> >    $qry2 = pg_exec ($conn,$sql2);
> >
> > ----8<------- CUT ----
> >
> > The second query is nested in a for-loop running for every object in the
> > first query; for performance reason I need to maintain the two queries
> > independent.
> >
> > After executing (correctly) the first one, the system starts doing
strange
> > things with the second one:
> >
> > Warning: Unable to jump to row 0 on PostgreSQL result index 23 in
cerca.php3
> > on line 467
> >
> > and it fails to read data.
> > The strange thing is that the system does the same things for EVERY
database
> > where I must use two consecutive queries !
> >
> > Is there anyone who can help me ?
> >
> > Thanks in advance
> >
> > Luca Lazzeroni
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to