resource pg_prepare(resource conn, string stmt, string query) resource pg_prepare(resource conn, string query)

Available as of PHP 5.1 and supported by PostgreSQL 7.4 and greater, pg_prepare() creates a prepared statement to be executed by pg_execute() or pg_send_execute(). A prepared statement might look like this:

$query = "INSERT INTO product (productcode, name, price, description) VALUES($1, $2, $3, $4)";

Note the use of placeholders ($1, $2, $3, $4) to represent the values that will be passed along later when the statement is executed. Not surprisingly, the number of placeholders must match the number of columns. A complete example involving this function is offered next in the introduction to pg_execute().

Was this article helpful?

+1 0

Post a comment