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

Re: Support for prepared queries

From: "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com>
To: Martin Marques <martin(at)bugs(dot)unl(dot)edu(dot)ar>
Cc: Robby Russell <rrussell(at)commandprompt(dot)com>,Stephen <jleelim(at)xxxxxx(dot)com>, <pgsql-php(at)postgresql(dot)org>
Subject: Re: Support for prepared queries
Date: 2003-10-24 22:30:01
Message-ID: Pine.LNX.4.33.0310241623570.26036-100000@css120.ihs.com (view raw or flat)
Thread:
Lists: pgsql-php
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:

<?php
$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))."<BR>";
?>

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.


In response to

Responses

pgsql-php by date

Next:From: Christopher Kings-LynneDate: 2003-10-26 08:20:06
Subject: Re: Support for prepared queries
Previous:From: Martin MarquesDate: 2003-10-24 21:50:56
Subject: Re: Support for prepared queries

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