Statement
extends
ResultStatement
in
Statement interface.
Drivers must implement this interface.
This resembles (a subset of) the PDOStatement interface.
Tags
Table of Contents
- bindParam() : bool
- 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.
- bindValue() : bool
- 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.
- closeCursor() : bool
- Closes the cursor, enabling the statement to be executed again.
- columnCount() : int
- Returns the number of columns in the result set
- errorCode() : string
- Fetches the SQLSTATE associated with the last operation on the statement handle.
- errorInfo() : array<string|int, mixed>
- Fetches extended error information associated with the last operation on the statement handle.
- execute() : bool
- Executes a prepared statement
- fetch() : mixed
- Returns the next row of a result set.
- fetchAll() : array<string|int, mixed>
- Returns an array containing all of the result set rows.
- fetchColumn() : string|bool
- Returns a single column from the next row of a result set or FALSE if there are no more rows.
- rowCount() : int
- Returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement executed by the corresponding object.
- setFetchMode() : bool
- Sets the fetch mode to use while iterating this statement.
Methods
bindParam()
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.
public
bindParam(mixed $column, mixed &$variable[, int|null $type = null ][, int|null $length = null ]) : bool
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
- $column : mixed
-
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.
- $variable : mixed
-
Name of the PHP variable to bind to the SQL statement parameter.
- $type : int|null = null
-
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.
- $length : int|null = null
-
You must specify maxlength when using an OUT bind so that PHP allocates enough memory to hold the returned value.
Return values
bool —TRUE on success or FALSE on failure.
bindValue()
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.
public
bindValue(mixed $param, mixed $value[, int $type = null ]) : bool
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
- $param : mixed
-
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.
- $value : mixed
-
The value to bind to the parameter.
- $type : int = null
-
Explicit data type for the parameter using the PDO::PARAM_* constants.
Return values
bool —TRUE on success or FALSE on failure.
closeCursor()
Closes the cursor, enabling the statement to be executed again.
public
closeCursor() : bool
Return values
bool —TRUE on success or FALSE on failure.
columnCount()
Returns the number of columns in the result set
public
columnCount() : int
Return values
int —The number of columns in the result set represented by the PDOStatement object. If there is no result set, this method should return 0.
errorCode()
Fetches the SQLSTATE associated with the last operation on the statement handle.
public
errorCode() : string
Tags
Return values
string —The error code string.
errorInfo()
Fetches extended error information associated with the last operation on the statement handle.
public
errorInfo() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —The error info array.
execute()
Executes a prepared statement
public
execute([array<string|int, mixed>|null $params = null ]) : bool
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
- $params : array<string|int, mixed>|null = null
-
An array of values with as many elements as there are bound parameters in the SQL statement being executed.
Return values
bool —TRUE on success or FALSE on failure.
fetch()
Returns the next row of a result set.
public
fetch([int|null $fetchMode = null ]) : mixed
Parameters
- $fetchMode : int|null = null
-
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.
Tags
Return values
mixed —The return value of this method on success depends on the fetch mode. 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 ]) : array<string|int, mixed>
Parameters
- $fetchMode : int|null = null
-
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.
Tags
Return values
array<string|int, mixed> —fetchColumn()
Returns a single column from the next row of a result set or FALSE if there are no more rows.
public
fetchColumn(int $columnIndex) : string|bool
Parameters
- $columnIndex : int
-
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 values
string|bool —A single column in the next row of a result set, or FALSE if there are no more rows.
rowCount()
Returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement executed by the corresponding object.
public
rowCount() : int
If the last SQL statement executed by the associated Statement object was a SELECT statement, some databases may return the number of rows returned by that statement. However, this behaviour is not guaranteed for all databases and should not be relied on for portable applications.
Return values
int —The number of rows.
setFetchMode()
Sets the fetch mode to use while iterating this statement.
public
setFetchMode(int $fetchMode[, mixed $arg2 = null ][, mixed $arg3 = null ]) : bool
Parameters
- $fetchMode : int
-
The fetch mode must be one of the PDO::FETCH_* constants.
- $arg2 : mixed = null
- $arg3 : mixed = null