class PDOStatement extends PDOStatement implements Statement (View source)

The PDO implementation of the Statement interface.

Used by all PDO-based drivers.

Methods

__construct()

Protected constructor.

boolean
setFetchMode(integer $fetchMode, mixed $arg2 = null, mixed $arg3 = null)

Sets the fetch mode to use while iterating this statement.

boolean
bindValue(mixed $param, mixed $value, integer $type = \PDO::PARAM_STR)

Binds a value to a corresponding named (not supported by mysqli driver, see comment below) or positional placeholder in the SQL statement that was used to prepare the statement.

boolean
bindParam(mixed $column, mixed $variable, integer|null $type = \PDO::PARAM_STR, integer|null $length = null, $driverOptions = null)

Binds a PHP variable to a corresponding named (not supported by mysqli driver, see comment below) or question mark placeholder in the SQL statement that was use to prepare the statement. Unlike PDOStatement->bindValue(), the variable is bound as a reference and will only be evaluated at the time that PDOStatement->execute() is called.

boolean
closeCursor()

Closes the cursor, enabling the statement to be executed again.

boolean
execute(array|null $params = null)

Executes a prepared statement

mixed
fetch(int|null $fetchMode = null, int $cursorOrientation = \PDO::FETCH_ORI_NEXT, int $cursorOffset = 0)

Returns the next row of a result set.

array
fetchAll(int|null $fetchMode = null, int|null $fetchArgument = null, array|null $ctorArgs = null)

Returns an array containing all of the result set rows.

string|boolean
fetchColumn(integer $columnIndex = 0)

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

Details

protected __construct()

Protected constructor.

boolean setFetchMode(integer $fetchMode, mixed $arg2 = null, mixed $arg3 = null)

Sets the fetch mode to use while iterating this statement.

Parameters

integer $fetchMode The fetch mode must be one of the PDO::FETCH_* constants.
mixed $arg2
mixed $arg3

Return Value

boolean

boolean bindValue(mixed $param, mixed $value, integer $type = \PDO::PARAM_STR)

Binds a value to a corresponding named (not supported by mysqli driver, see comment below) or positional placeholder in the SQL statement that was used to prepare the statement.

As mentioned above, the named parameters are not natively supported by the mysqli driver, use executeQuery(), fetchAll(), fetchArray(), fetchColumn(), fetchAssoc() methods to have the named parameter emulated by doctrine.

Parameters

mixed $param Parameter identifier. For a prepared statement using named placeholders, this will be a parameter name of the form :name. For a prepared statement using question mark placeholders, this will be the 1-indexed 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 TRUE on success or FALSE on failure.

boolean bindParam(mixed $column, mixed $variable, integer|null $type = \PDO::PARAM_STR, integer|null $length = null, $driverOptions = null)

Binds a PHP variable to a corresponding named (not supported by mysqli driver, see comment below) or question mark placeholder in the SQL statement that was use to prepare the statement. Unlike PDOStatement->bindValue(), the variable is bound as a reference and will only be evaluated at the time that PDOStatement->execute() is called.

As mentioned above, the named parameters are not natively supported by the mysqli driver, use executeQuery(), fetchAll(), fetchArray(), fetchColumn(), fetchAssoc() methods to have the named parameter emulated by doctrine.

Most parameters are input parameters, that is, parameters that are used in a read-only fashion to build up the query. Some drivers support the invocation of stored procedures that return data as output parameters, and some also as input/output parameters that both send in data and are updated to receive it.

Parameters

mixed $column Parameter identifier. For a prepared statement using named placeholders, this will be a parameter name of the form :name. For a prepared statement using question mark placeholders, this will be the 1-indexed position of the parameter.
mixed $variable Name of the PHP variable to bind to the SQL statement parameter.
integer|null $type Explicit data type for the parameter using the PDO::PARAM_* constants. To return an INOUT parameter from a stored procedure, use the bitwise OR operator to set the PDO::PARAM_INPUT_OUTPUT bits for the data_type parameter.
integer|null $length You must specify maxlength when using an OUT bind so that PHP allocates enough memory to hold the returned value.
$driverOptions

Return Value

boolean TRUE on success or FALSE on failure.

boolean closeCursor()

Closes the cursor, enabling the statement to be executed again.

Return Value

boolean TRUE on success or FALSE on failure.

boolean execute(array|null $params = null)

Executes a prepared statement

If the prepared statement included parameter markers, you must either: call PDOStatement->bindParam() to bind PHP variables to the parameter markers: bound variables pass their value as input and receive the output value, if any, of their associated parameter markers or pass an array of input-only parameter values.

Parameters

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

Return Value

boolean TRUE on success or FALSE on failure.

mixed fetch(int|null $fetchMode = null, int $cursorOrientation = \PDO::FETCH_ORI_NEXT, int $cursorOffset = 0)

Returns the next row of a result set.

Parameters

int|null $fetchMode Controls how the next row will be returned to the caller. The value must be one of the \PDO::FETCH_* constants, defaulting to \PDO::FETCH_BOTH.
int $cursorOrientation For a ResultStatement object representing a scrollable cursor, this value determines which row will be returned to the caller. This value must be one of the \PDO::FETCH_ORI_* constants, defaulting to \PDO::FETCH_ORI_NEXT. To request a scrollable cursor for your ResultStatement object, you must set the \PDO::ATTR_CURSOR attribute to \PDO::CURSOR_SCROLL when you prepare the SQL statement with \PDO::prepare().
int $cursorOffset For a ResultStatement object representing a scrollable cursor for which the cursorOrientation parameter is set to \PDO::FETCH_ORI_ABS, this value specifies the absolute number of the row in the result set that shall be fetched. For a ResultStatement object representing a scrollable cursor for which the cursorOrientation parameter is set to \PDO::FETCH_ORI_REL, this value specifies the row to fetch relative to the cursor position before ResultStatement::fetch() was called.

Return Value

mixed The return value of this method on success depends on the fetch mode. In all cases, FALSE is returned on failure.

array fetchAll(int|null $fetchMode = null, int|null $fetchArgument = null, array|null $ctorArgs = null)

Returns an array containing all of the result set rows.

Parameters

int|null $fetchMode Controls how the next row will be returned to the caller. The value must be one of the \PDO::FETCH_* constants, defaulting to \PDO::FETCH_BOTH.
int|null $fetchArgument This argument has a different meaning depending on the value of the $fetchMode parameter: * \PDO::FETCH_COLUMN: Returns the indicated 0-indexed column. * \PDO::FETCH_CLASS: Returns instances of the specified class, mapping the columns of each row to named properties in the class. * \PDO::FETCH_FUNC: Returns the results of calling the specified function, using each row's columns as parameters in the call.
array|null $ctorArgs Controls how the next row will be returned to the caller. The value must be one of the \PDO::FETCH_* constants, defaulting to \PDO::FETCH_BOTH.

Return Value

array

string|boolean fetchColumn(integer $columnIndex = 0)

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

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|boolean A single column in the next row of a result set, or FALSE if there are no more rows.