Thread: Does php/postgres support placeholder's?

Does php/postgres support placeholder's?

From
"John Mohr"
Date:
Does php/postgres support placeholder's in queries and updates. Something that looks like "select * from x where key=?" ? I notice that the call interface doesn't support all of the documented calls, for example pg_query and pg_send_query, but not pg_query_params (according to pgsql.c, the postgres php -> postgres interface program).

Re: Does php/postgres support placeholder's?

From
John DeSoi
Date:
On Apr 27, 2005, at 4:47 PM, John Mohr wrote:

> Does php/postgres support placeholder's in queries and updates.
> Something that looks like "select * from x where key=?" ? I notice
> that the call interface doesn't support all of the documented calls,
> for example pg_query and pg_send_query, but not pg_query_params
> (according to pgsql.c, the postgres php -> postgres interface
> program).

I see docs for pg_prepare and pg_execute and execute, but it may only
be in the CVS version. I seem to recall a recent mention on the list
that a more complete interface is coming with PHP 5.1.

http://www.php.net/manual/en/ref.pgsql.php

John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL


Re: Does php/postgres support placeholder's?

From
Christopher Kings-Lynne
Date:
It has special functions for it in 5.1 CVS, but not in release.
However, you can just do it yourself using the PREPARE and EXECUTE
statements:

http://www.postgresql.org/docs/8.0/interactive/sql-prepare.html
http://www.postgresql.org/docs/8.0/interactive/sql-execute.html

Chris


John Mohr wrote:
>
> Does php/postgres support placeholder's in queries and updates.
> Something that looks like "select * from x where key=?" ? I notice that
> the call interface doesn't support all of the documented calls, for
> example pg_query and pg_send_query, but not pg_query_params (according
> to pgsql.c, the postgres php -> postgres interface program).

Does php/postgres support placeholder's?

From
Volkan YAZICI
Date:
Hi,

On 4/27/05, John Mohr <jtmohr@healthconresources.com> wrote:
> Does php/postgres support placeholder's in queries and updates. Something
> that looks like "select * from x where key=?" ?

I think you meant parameters by "placeholders". For example:

INSERT INTO tbl (f1, f2, f3...) VALUES ($1, $2, $3, ...);
SELECT count(oid) FROM tbl WHERE field = $1;

AFAIC, PHP PostgreSQL API doesn't support any X_params() functions.
(Seems like stucked in escapeThatBuggyString() functions.)

> I notice that the call
> interface doesn't support all of the documented calls, for example pg_query
> and pg_send_query, but not pg_query_params (according to pgsql.c, the
> postgres php -> postgres interface program).

Some of the functions I found that don't exist in both latest release
and CVS tree:

pg_prepare()
pg_query_params()
pg_field_type_oid()
pg_send_prepare()
pg_send_query_params()

(CVS checkout for ext/pgsql/pgsql.c:
http://cvs.php.net/co.php/php-src/ext/pgsql/pgsql.c?r=1.244.2.38)

Also, async query functions' interface is new as well. (Committed @
"Sat Mar 19 03:46:55 2005" Related diff:
http://cvs.php.net/php-src/ext/pgsql/pgsql.c?r1=1.315&onb=0)

Regards.