class Statement implements IteratorAggregate, Statement (View source)

A thin wrapper around a Doctrine\DBAL\Driver\Statement that adds support for logging, DBAL mapping types, etc.

Properties

protected string $sql
protected array $params
protected Statement $stmt
protected AbstractPlatform $platform
protected Connection $conn

Methods

__construct(string $sql, Connection $conn)

Creates a new Statement for the given SQL and Connection.

boolean
bindValue($name, mixed $value, integer $type = null)

Binds a parameter value to the statement.

boolean
bindParam($name, $var, $type = PDO::PARAM_STR)

Binds a parameter to a value by reference.

boolean
execute(array $params = null)

Executes the statement with the currently bound parameters.

boolean
closeCursor()

Closes the cursor, freeing the database resources used by this statement.

integer
columnCount()

Returns the number of columns in the result set.

string
errorCode()

Fetches the SQLSTATE associated with the last operation on the statement.

array
errorInfo()

Fetches extended error information associated with the last operation on the statement.

setFetchMode($fetchStyle, $arg2 = null, $arg3 = null)

setFetchMode Set the fetch mode to use while iterating this statement.

getIterator()

No description

mixed
fetch($fetchStyle = PDO::FETCH_BOTH)

Fetches the next row from a result set.

array
fetchAll($fetchStyle = PDO::FETCH_BOTH, mixed $fetchArgument = 0)

Returns an array containing all of the result set rows.

string
fetchColumn(integer $columnIndex = 0)

Returns a single column from the next row of a result set.

integer
rowCount()

Returns the number of rows affected by the last execution of this statement.

Statement
getWrappedStatement()

Gets the wrapped driver statement.

Details

__construct(string $sql, Connection $conn)

Creates a new Statement for the given SQL and Connection.

Parameters

string $sql The SQL of the statement.
Connection $conn The connection on which the statement should be executed.

boolean bindValue($name, mixed $value, integer $type = null)

Binds a parameter value to the statement.

The value can optionally be bound with a PDO binding type or a DBAL mapping type. If bound with a DBAL mapping type, the binding type is derived from the mapping type and the value undergoes the conversion routines of the mapping type before being bound.

Parameters

$name The name or position of the parameter.
mixed $value The value to bind to the parameter.
integer $type Explicit data type for the parameter using the PDO::PARAM_* constants.

Return Value

boolean Returns TRUE on success or FALSE on failure.

boolean bindParam($name, $var, $type = PDO::PARAM_STR)

Binds a parameter to a value by reference.

Binding a parameter by reference does not support DBAL mapping types.

Parameters

$name
$var
$type

Return Value

boolean Returns TRUE on success or FALSE on failure.

boolean execute(array $params = null)

Executes the statement with the currently bound parameters.

Parameters

array $params An array of values with as many elements as there are bound parameters in the SQL statement being executed.

Return Value

boolean Returns TRUE on success or FALSE on failure.

boolean closeCursor()

Closes the cursor, freeing the database resources used by this statement.

Return Value

boolean Returns TRUE on success or FALSE on failure.

integer columnCount()

Returns the number of columns in the result set.

Return Value

integer Returns the number of columns in the result set represented by the PDOStatement object. If there is no result set, this method should return 0.

string errorCode()

Fetches the SQLSTATE associated with the last operation on the statement.

Return Value

string error code string

array errorInfo()

Fetches extended error information associated with the last operation on the statement.

Return Value

array error info array

setFetchMode($fetchStyle, $arg2 = null, $arg3 = null)

setFetchMode Set the fetch mode to use while iterating this statement.

Parameters

$fetchStyle
$arg2
$arg3

getIterator()

mixed fetch($fetchStyle = PDO::FETCH_BOTH)

Fetches the next row from a result set.

Parameters

$fetchStyle

Return Value

mixed

array fetchAll($fetchStyle = PDO::FETCH_BOTH, mixed $fetchArgument = 0)

Returns an array containing all of the result set rows.

Parameters

$fetchStyle
mixed $fetchArgument

Return Value

array

string fetchColumn(integer $columnIndex = 0)

Returns a single column from the next row of a result set.

Parameters

integer $columnIndex 0-indexed number of the column you wish to retrieve from the row. If no value is supplied, PDOStatement->fetchColumn() fetches the first column.

Return Value

string returns a single column in the next row of a result set.

integer rowCount()

Returns the number of rows affected by the last execution of this statement.

Return Value

integer Returns the number of rows.

Statement getWrappedStatement()

Gets the wrapped driver statement.

Return Value

Statement