class Statement (View source)

A named prepared statement.

See pq\Connection::prepare().

Properties

Connection read-only $connection

The connection to the server.

string read-only $name

The identifiying name of the prepared statement.

string read-only $query

The query string used to prepare the statement.

array read-only $types

List of corresponding query parameter type OIDs for the prepared statement.

Methods

__construct(Connection $conn, string $name, string $query, array $types = null, bool $async = false)

Prepare a new statement.

bind(int $param_no, mixed $param_ref)

Bind a variable to an input parameter.

deallocate()

Free the server resources used by the prepared statement, so it can no longer be executed.

deallocateAsync()

[Asynchronously](pq/Connection/: Asynchronous Usage) free the server resources used by the prepared statement, so it can no longer be executed.

array
desc()

Describe the parameters of the prepared statement.

descAsync(callable $callback)

[Asynchronously](pq/Connection/: Asynchronous Usage) describe the parameters of the prepared statement.

exec(array $params = null)

Execute the prepared statement.

execAsync(array $params = null, callable $cb = null)

[Asynchronously](pq/Connection/: Asynchronous Usage) execute the prepared statement.

prepare()

Re-prepare a statement that has been deallocated. This is a no-op on already open statements.

prepareAsync()

[Asynchronously](pq/Connection/: Asynchronous Usage) re-prepare a statement that has been deallocated. This is a no-op on already open statements.

Details

__construct(Connection $conn, string $name, string $query, array $types = null, bool $async = false)

Prepare a new statement.

See pq\Connection::prepare().

Parameters

Connection $conn

The connection to prepare the statement on.

string $name

The name identifying this statement.

string $query

The actual query to prepare.

array $types

A list of corresponding query parameter type OIDs.

bool $async

Whether to prepare the statement [asynchronously](pq/Connection/: Asynchronous Usage).

Exceptions

InvalidArgumentException
BadMethodCallException
RuntimeException
DomainException

bind(int $param_no, mixed $param_ref)

Bind a variable to an input parameter.

Parameters

int $param_no

The parameter index to bind to.

mixed $param_ref

The variable to bind.

Exceptions

InvalidArgumentException
BadMethodCallException

deallocate()

Free the server resources used by the prepared statement, so it can no longer be executed.

This is done implicitly when the object is destroyed.

deallocateAsync()

[Asynchronously](pq/Connection/: Asynchronous Usage) free the server resources used by the prepared statement, so it can no longer be executed.

array desc()

Describe the parameters of the prepared statement.

Return Value

array

list of type OIDs of the substitution parameters.

Exceptions

InvalidArgumentException
BadMethodCallException
RuntimeException
DomainException

descAsync(callable $callback)

[Asynchronously](pq/Connection/: Asynchronous Usage) describe the parameters of the prepared statement.

Parameters

callable $callback

as function(array $oids) A callback to receive list of type OIDs of the substitution parameters.

Exceptions

InvalidArgumentException
BadMethodCallException
RuntimeException

Result exec(array $params = null)

Execute the prepared statement.

Parameters

array $params

Any parameters to substitute in the prepared statement (defaults to any bou nd variables).

Return Value

Result

the result of the execution of the prepared statement.

Exceptions

InvalidArgumentException
BadMethodCallException
RuntimeException

execAsync(array $params = null, callable $cb = null)

[Asynchronously](pq/Connection/: Asynchronous Usage) execute the prepared statement.

Parameters

array $params

Any parameters to substitute in the prepared statement (defaults to any bou nd variables).

callable $cb

as function(\pq\Result $res) : void Result handler callback.

Exceptions

InvalidArgumentException
BadMethodCallException
RuntimeException

prepare()

Re-prepare a statement that has been deallocated. This is a no-op on already open statements.

prepareAsync()

[Asynchronously](pq/Connection/: Asynchronous Usage) re-prepare a statement that has been deallocated. This is a no-op on already open statements.