Support for prepared queries

Support for prepared queries

am 21.10.2003 07:58:24 von Stephen

Hi,

Does anyone know if PHP supports prepared queries for PostgreSQL 7.3.x ? If
not, when will prepared queries be supported?

Thanks, Stephen



---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Re: Support for prepared queries

am 24.10.2003 20:02:08 von Robby Russell

Stephen wrote:
> Hi,
>
> Does anyone know if PHP supports prepared queries for PostgreSQL 7.3.x ? If
> not, when will prepared queries be supported?
>
> Thanks, Stephen
>

You might want to look at PEAR db. I think it comes with php standard
now... so pear.php.net.

-Robby

--
Robby Russell, | Sr. Administrator / Lead Programmer
Command Prompt, Inc. | http://www.commandprompt.com
rrussell@commandprompt.com | Telephone: (503) 222.2783


---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Re: Support for prepared queries

am 24.10.2003 23:47:27 von Martin Marques

El Mar 21 Oct 2003 02:58, Stephen escribi=F3:
> Hi,
>=20
> Does anyone know if PHP supports prepared queries for PostgreSQL 7.3.x ? =
If
> not, when will prepared queries be supported?

No it doesn't. I tried to contact the developers of the PGSQL extension, bu=
t=20
had no feed back. :-(

--=20
select 'mmarques' || '@' || 'unl.edu.ar' AS email;
------------------------------------------------------------ -----
Mart=EDn Marqu=E9s | mmarques@unl.edu.ar
Programador, Administrador, DBA | Centro de Telem=E1tica
Universidad Nacional
del Litoral
------------------------------------------------------------ -----


---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Re: Support for prepared queries

am 24.10.2003 23:50:56 von Martin Marques

El Vie 24 Oct 2003 15:02, Robby Russell escribi=F3:
> Stephen wrote:
> > Hi,
> >=20
> > Does anyone know if PHP supports prepared queries for PostgreSQL 7.3.x =
?=20
If
> > not, when will prepared queries be supported?
> >=20
> > Thanks, Stephen
> >=20
>=20
> You might want to look at PEAR db. I think it comes with php standard=20
> now... so pear.php.net.

Those are not prepared queries (at least in the sence of prepare -> execute=
).
For prepared queries you have to know how to talk to libpq, and that's=20
something that is done from the pgsql ext.

--=20
select 'mmarques' || '@' || 'unl.edu.ar' AS email;
------------------------------------------------------------ -----
Mart=EDn Marqu=E9s | mmarques@unl.edu.ar
Programador, Administrador, DBA | Centro de Telem=E1tica
Universidad Nacional
del Litoral
------------------------------------------------------------ -----


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

Re: Support for prepared queries

am 25.10.2003 00:30:01 von Scott Marlowe

On Fri, 24 Oct 2003, Martin Marques wrote:

> El Vie 24 Oct 2003 15:02, Robby Russell escribió:
> > Stephen wrote:
> > > Hi,
> > >
> > > Does anyone know if PHP supports prepared queries for PostgreSQL 7.3.x ?
> If
> > > not, when will prepared queries be supported?
> > >
> > > Thanks, Stephen
> > >
> >
> > You might want to look at PEAR db. I think it comes with php standard
> > now... so pear.php.net.
>
> Those are not prepared queries (at least in the sence of prepare -> execute).
> For prepared queries you have to know how to talk to libpq, and that's
> something that is done from the pgsql ext.

This hunk of code works fine on my php 4.3.2 / postgresql 7.3.4 box:

$conn = pg_connect("dbname=marl8412 user=marl8412");
$a = pg_query($conn,"prepare test (int4) as select * from accounts where
aid= $1");
$res = pg_query($conn,"execute test (45)");
$row = pg_fetch_row($res);
print implode(" ",array_values($row))."
";
?>

so yes, you can use a prepared queries in PHP. But, they won't live
across connections I don't think. Or at least I'm pretty sure you can't
count on them living from one page to the next. but if you're gonna have
a page where you run the same select with different select parameters over
and over it might be a win.


---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Re: Support for prepared queries

am 26.10.2003 09:20:06 von Christopher Kings-Lynne

>> Does anyone know if PHP supports prepared queries for PostgreSQL 7.3.x
>> ? If
>> not, when will prepared queries be supported?

Yes they are. Read the docs regarding the 'PREPARE' and 'EXECUTE'
commands in the Reference Manual. There is not special PHP support
required for this.

Chris


---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Re: Support for prepared queries

am 31.10.2003 17:35:22 von Stephen

Any idea how the prepared query can be made to save across PHP invocations?
How about using pg_pconnect (persistent connection), will it stay prepared
when PHP comes again and reuse the connection?

Stephen


""scott.marlowe"" wrote in message
news:Pine.LNX.4.33.0310241623570.26036-100000@css120.ihs.com ...
> On Fri, 24 Oct 2003, Martin Marques wrote:
>
> > El Vie 24 Oct 2003 15:02, Robby Russell escribió:
> > > Stephen wrote:
> > > > Hi,
> > > >
> > > > Does anyone know if PHP supports prepared queries for PostgreSQL
7.3.x ?
> > If
> > > > not, when will prepared queries be supported?
> > > >
> > > > Thanks, Stephen
> > > >
> > >
> > > You might want to look at PEAR db. I think it comes with php standard
> > > now... so pear.php.net.
> >
> > Those are not prepared queries (at least in the sence of prepare ->
execute).
> > For prepared queries you have to know how to talk to libpq, and that's
> > something that is done from the pgsql ext.
>
> This hunk of code works fine on my php 4.3.2 / postgresql 7.3.4 box:
>
> > $conn = pg_connect("dbname=marl8412 user=marl8412");
> $a = pg_query($conn,"prepare test (int4) as select * from accounts where
> aid= $1");
> $res = pg_query($conn,"execute test (45)");
> $row = pg_fetch_row($res);
> print implode(" ",array_values($row))."
";
> ?>
>
> so yes, you can use a prepared queries in PHP. But, they won't live
> across connections I don't think. Or at least I'm pretty sure you can't
> count on them living from one page to the next. but if you're gonna have
> a page where you run the same select with different select parameters over
> and over it might be a win.
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: the planner will ignore your desire to choose an index scan if your
> joining column's datatypes do not match
>



---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Re: Support for prepared queries

am 04.11.2003 22:22:32 von Scott Marlowe

No, in fact in PHP5 php now purposely resets the connection between pages.

You'd have to write some kind of pooling solution to get that kind of
behaviour. I don't know of anyone working on pooling in PHP.

On Fri, 31 Oct 2003, Stephen wrote:

> Any idea how the prepared query can be made to save across PHP invocations?
> How about using pg_pconnect (persistent connection), will it stay prepared
> when PHP comes again and reuse the connection?
>
> Stephen
>
>
> ""scott.marlowe"" wrote in message
> news:Pine.LNX.4.33.0310241623570.26036-100000@css120.ihs.com ...
> > On Fri, 24 Oct 2003, Martin Marques wrote:
> >
> > > El Vie 24 Oct 2003 15:02, Robby Russell escribió:
> > > > Stephen wrote:
> > > > > Hi,
> > > > >
> > > > > Does anyone know if PHP supports prepared queries for PostgreSQL
> 7.3.x ?
> > > If
> > > > > not, when will prepared queries be supported?
> > > > >
> > > > > Thanks, Stephen
> > > > >
> > > >
> > > > You might want to look at PEAR db. I think it comes with php standard
> > > > now... so pear.php.net.
> > >
> > > Those are not prepared queries (at least in the sence of prepare ->
> execute).
> > > For prepared queries you have to know how to talk to libpq, and that's
> > > something that is done from the pgsql ext.
> >
> > This hunk of code works fine on my php 4.3.2 / postgresql 7.3.4 box:
> >
> > > > $conn = pg_connect("dbname=marl8412 user=marl8412");
> > $a = pg_query($conn,"prepare test (int4) as select * from accounts where
> > aid= $1");
> > $res = pg_query($conn,"execute test (45)");
> > $row = pg_fetch_row($res);
> > print implode(" ",array_values($row))."
";
> > ?>
> >
> > so yes, you can use a prepared queries in PHP. But, they won't live
> > across connections I don't think. Or at least I'm pretty sure you can't
> > count on them living from one page to the next. but if you're gonna have
> > a page where you run the same select with different select parameters over
> > and over it might be a win.
> >
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 9: the planner will ignore your desire to choose an index scan if your
> > joining column's datatypes do not match
> >
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: the planner will ignore your desire to choose an index scan if your
> joining column's datatypes do not match
>
>


---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Re: Support for prepared queries

am 05.11.2003 16:38:57 von Scott Marlowe

Hey, I found this on sourceforge:

http://sqlrelay.sourceforge.net/

No clue how well it works, but I might give it a try.

On Tue, 4 Nov 2003, scott.marlowe wrote:

> No, in fact in PHP5 php now purposely resets the connection between pag=
es.
>=20
> You'd have to write some kind of pooling solution to get that kind of=20
> behaviour. I don't know of anyone working on pooling in PHP.
>=20
> On Fri, 31 Oct 2003, Stephen wrote:
>=20
> > Any idea how the prepared query can be made to save across PHP invoca=
tions?
> > How about using pg_pconnect (persistent connection), will it stay pre=
pared
> > when PHP comes again and reuse the connection?
> >=20
> > Stephen
> >=20
> >=20
> > ""scott.marlowe"" wrote in message
> > news:Pine.LNX.4.33.0310241623570.26036-100000@css120.ihs.com ...
> > > On Fri, 24 Oct 2003, Martin Marques wrote:
> > >
> > > > El Vie 24 Oct 2003 15:02, Robby Russell escribi=F3:
> > > > > Stephen wrote:
> > > > > > Hi,
> > > > > >
> > > > > > Does anyone know if PHP supports prepared queries for Postgre=
SQL
> > 7.3.x ?
> > > > If
> > > > > > not, when will prepared queries be supported?
> > > > > >
> > > > > > Thanks, Stephen
> > > > > >
> > > > >
> > > > > You might want to look at PEAR db. I think it comes with php st=
andard
> > > > > now... so pear.php.net.
> > > >
> > > > Those are not prepared queries (at least in the sence of prepare =
->
> > execute).
> > > > For prepared queries you have to know how to talk to libpq, and t=
hat's
> > > > something that is done from the pgsql ext.
> > >
> > > This hunk of code works fine on my php 4.3.2 / postgresql 7.3.4 box=
:
> > >
> > > > > > $conn =3D pg_connect("dbname=3Dmarl8412 user=3Dmarl8412");
> > > $a =3D pg_query($conn,"prepare test (int4) as select * from account=
s where
> > > aid=3D $1");
> > > $res =3D pg_query($conn,"execute test (45)");
> > > $row =3D pg_fetch_row($res);
> > > print implode(" ",array_values($row))."
";
> > > ?>
> > >
> > > so yes, you can use a prepared queries in PHP. But, they won't liv=
e
> > > across connections I don't think. Or at least I'm pretty sure you =
can't
> > > count on them living from one page to the next. but if you're gonn=
a have
> > > a page where you run the same select with different select paramete=
rs over
> > > and over it might be a win.
> > >
> > >
> > > ---------------------------(end of broadcast)----------------------=
-----
> > > TIP 9: the planner will ignore your desire to choose an index scan =
if your
> > > joining column's datatypes do not match
> > >
> >=20
> >=20
> >=20
> > ---------------------------(end of broadcast)------------------------=
---
> > TIP 9: the planner will ignore your desire to choose an index scan if=
your
> > joining column's datatypes do not match
> >=20
> >=20
>=20
>=20
> ---------------------------(end of broadcast)--------------------------=
-
> TIP 7: don't forget to increase your free space map settings
>=20
>=20


---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Re: Support for prepared queries

am 06.11.2003 23:53:54 von Bruce Momjian

scott.marlowe wrote:
> No, in fact in PHP5 php now purposely resets the connection between pages.
>
> You'd have to write some kind of pooling solution to get that kind of
> behaviour. I don't know of anyone working on pooling in PHP.

Thought PHP5 does RESET ALL, that doesn't affect prepared queries, only
SET variables.

--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Re: Support for prepared queries

am 07.11.2003 03:31:34 von Christopher Kings-Lynne

>>You'd have to write some kind of pooling solution to get that kind of
>>behaviour. I don't know of anyone working on pooling in PHP.
>
>
> Thought PHP5 does RESET ALL, that doesn't affect prepared queries, only
> SET variables.

I vote for a new command:

RESET SESSION;

Basically, we make that connection reset everythign - SET variables,
open cursors, etc. I don't think we want to clobber prepared
queries...i dunno.

And we can add stuff to it without needing pool managers to change how
they do things.

Chris





---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Re: Support for prepared queries

am 07.11.2003 17:44:17 von Scott Marlowe

On Thu, 6 Nov 2003, Bruce Momjian wrote:

> scott.marlowe wrote:
> > No, in fact in PHP5 php now purposely resets the connection between pages.
> >
> > You'd have to write some kind of pooling solution to get that kind of
> > behaviour. I don't know of anyone working on pooling in PHP.
>
> Thought PHP5 does RESET ALL, that doesn't affect prepared queries, only
> SET variables.

But since your not guaranteeds your original connection in PHP, might
there still be some issues?


---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Re: Support for prepared queries

am 12.11.2003 04:52:55 von Bruce Momjian

Should this be a TODO item?

------------------------------------------------------------ ---------------

Christopher Kings-Lynne wrote:
>
> >>You'd have to write some kind of pooling solution to get that kind of
> >>behaviour. I don't know of anyone working on pooling in PHP.
> >
> >
> > Thought PHP5 does RESET ALL, that doesn't affect prepared queries, only
> > SET variables.
>
> I vote for a new command:
>
> RESET SESSION;
>
> Basically, we make that connection reset everythign - SET variables,
> open cursors, etc. I don't think we want to clobber prepared
> queries...i dunno.
>
> And we can add stuff to it without needing pool managers to change how
> they do things.
>
> Chris
>
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings