(no version information, might be only in CVS)

pg_send_execute -- Asynchronously execute a previously prepared query


resource pg_send_execute ( string stmtname, array params )

resource pg_send_execute ( resource connection, string stmtname, array params )

pg_send_execute() executes a previously prepared named query on the connection, with the specified parameters. Unlike pg_execute(), script execution is not blocked while the query is executing.

pg_send_execute() returns a query result resource if the named prepared query could be executed with the given parameters. It returns FALSE on failure or if connection is not a valid connection. It is identical to pg_send_query_params() except that it takes the name of a previously prepared query instead of an actual query.


Exemple 1. Using pg_send_execute()

= pg_connect("dbname=publisher") or die("Could not connect");

// Prepare a query for execution
if (!pg_connection_busy($dbconn)) {
pg_send_prepare($dbconn, "my_query", 'SELECT * FROM shops WHERE name = $1');
$res1 = pg_get_result($dbconn);

// Execute the prepared query.  Note that it is not necessary to escape
  // the string "Joe's Widgets" in any way
if (!pg_connection_busy($dbconn)) {
pg_send_execute($dbconn, "my_query", array("Joe's Widgets"));
$res2 = pg_get_result($dbconn);
// Execute the same prepared query, this time with a different parameter
if (!pg_connection_busy($dbconn)) {
pg_send_execute($dbconn, "my_query", array("Clothes Clothes Clothes"));
$res3 = pg_get_result($dbconn);

Voir aussi