Documentation

Statement
in package
implements IteratorAggregate, Statement

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

Tags
author

Roman Borschel roman@code-factory.org

since
2.0

Interfaces, Classes and Traits

IteratorAggregate
Statement
Statement interface.

Table of Contents

$conn  : Connection
The connection this statement is bound to and executed on.
$params  : array<string|int, mixed>
The bound parameters.
$platform  : AbstractPlatform
The underlying database platform.
$sql  : string
The SQL statement.
$stmt  : Statement
The underlying driver statement.
$types  : array<string|int, mixed>
The parameter types.
__construct()  : mixed
Creates a new <tt>Statement</tt> for the given SQL and <tt>Connection</tt>.
bindParam()  : bool
Binds a parameter to a value by reference.
bindValue()  : bool
Binds a parameter value to the statement.
closeCursor()  : bool
Closes the cursor, freeing the database resources used by this statement.
columnCount()  : int
Returns the number of columns in the result set.
errorCode()  : string
Fetches the SQLSTATE associated with the last operation on the statement.
errorInfo()  : array<string|int, mixed>
Fetches extended error information associated with the last operation on the statement.
execute()  : bool
Executes the statement with the currently bound parameters.
fetch()  : mixed
Fetches the next row from a result set.
fetchAll()  : array<string|int, mixed>
Returns an array containing all of the result set rows.
fetchColumn()  : mixed
Returns a single column from the next row of a result set.
getIterator()  : mixed
Required by interface IteratorAggregate.
getWrappedStatement()  : Statement
Gets the wrapped driver statement.
rowCount()  : int
Returns the number of rows affected by the last execution of this statement.
setFetchMode()  : mixed
{@inheritdoc}

Properties

$params

The bound parameters.

protected array<string|int, mixed> $params = array()

$sql

The SQL statement.

protected string $sql

$types

The parameter types.

protected array<string|int, mixed> $types = array()

Methods

__construct()

Creates a new <tt>Statement</tt> for the given SQL and <tt>Connection</tt>.

public __construct(string $sql, Connection $conn) : mixed
Parameters
$sql : string

The SQL of the statement.

$conn : Connection

The connection on which the statement should be executed.

Return values
mixed

bindParam()

Binds a parameter to a value by reference.

public bindParam(string $name, mixed &$var[, int $type = PDO::PARAM_STR ][, int|null $length = null ]) : bool

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

Parameters
$name : string

The name or position of the parameter.

$var : mixed

The reference to the variable to bind.

$type : int = PDO::PARAM_STR

The PDO binding type.

$length : int|null = null

Must be specified when using an OUT bind so that PHP allocates enough memory to hold the returned value.

Return values
bool

TRUE on success, FALSE on failure.

bindValue()

Binds a parameter value to the statement.

public bindValue(string $name, mixed $value[, mixed $type = null ]) : bool

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 : string

The name or position of the parameter.

$value : mixed

The value of the parameter.

$type : mixed = null

Either a PDO binding type or a DBAL mapping type name or instance.

Return values
bool

TRUE on success, FALSE on failure.

closeCursor()

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

public closeCursor() : bool
Return values
bool

TRUE on success, FALSE on failure.

columnCount()

Returns the number of columns in the result set.

public columnCount() : int
Return values
int

errorCode()

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

public errorCode() : string
Return values
string

errorInfo()

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

public errorInfo() : array<string|int, mixed>
Return values
array<string|int, mixed>

execute()

Executes the statement with the currently bound parameters.

public execute([array<string|int, mixed>|null $params = null ]) : bool
Parameters
$params : array<string|int, mixed>|null = null
Tags
throws
DBALException
Return values
bool

TRUE on success, FALSE on failure.

fetch()

Fetches the next row from a result set.

public fetch([int|null $fetchMode = null ]) : mixed
Parameters
$fetchMode : int|null = null
Return values
mixed

The return value of this function on success depends on the fetch type. In all cases, FALSE is returned on failure.

fetchAll()

Returns an array containing all of the result set rows.

public fetchAll([int|null $fetchMode = null ], mixed $fetchArgument) : array<string|int, mixed>
Parameters
$fetchMode : int|null = null
$fetchArgument : mixed
Return values
array<string|int, mixed>

An array containing all of the remaining rows in the result set.

fetchColumn()

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

public fetchColumn(int $columnIndex) : mixed
Parameters
$columnIndex : int
Return values
mixed

A single column from the next row of a result set or FALSE if there are no more rows.

getIterator()

Required by interface IteratorAggregate.

public getIterator() : mixed
Return values
mixed

rowCount()

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

public rowCount() : int
Return values
int

The number of affected rows.

setFetchMode()

{@inheritdoc}

public setFetchMode(mixed $fetchMode[, mixed $arg2 = null ][, mixed $arg3 = null ]) : mixed
Parameters
$fetchMode : mixed
$arg2 : mixed = null
$arg3 : mixed = null
Return values
mixed

Search results