StatementWrapper
class StatementWrapper implements IteratorAggregate, StatementInterface (View source)
Implementation of StatementInterface encapsulating PDOStatement.
Properties
| protected Connection | $connection | The Drupal database connection object. |
|
| protected object | $clientStatement | The client database Statement object. |
|
| protected bool | $rowCountEnabled | Is rowCount() execution allowed. |
Methods
Constructs a StatementWrapper object.
Implements the magic __get() method.
Implements the magic __set() method.
Returns the client-level database statement object.
{@inheritdoc}
Executes a prepared statement.
Gets the query string of this statement.
Returns an entire single column of a result set as an indexed array.
Returns the result set as an associative array keyed by the given field.
Returns the entire result set as a single associative array.
Returns a single field from the next record of a result set.
Fetches the next row and returns it as an associative array.
Fetches the next row and returns it as an object.
Returns the number of rows affected by the last SQL statement.
Sets the default fetch mode for this statement.
Fetches the next row from a result set.
Returns an array containing all of the result set rows.
{@inheritdoc}
Bind a column to a PHP variable.
Binds a parameter to the specified variable name.
Details
__construct(Connection $connection, object $client_connection, string $query, array $options, bool $row_count_enabled = FALSE)
Constructs a StatementWrapper object.
__get($name)
Implements the magic __get() method.
__set($name, $value)
Implements the magic __set() method.
__call($method, $arguments)
deprecated
deprecated
Implements the magic __call() method.
object
getClientStatement()
Returns the client-level database statement object.
This method should normally be used only within database driver code.
string
getConnectionTarget()
{@inheritdoc}
true
execute($args = [], $options = [])
Executes a prepared statement.
The
getQueryString()
Gets the query string of this statement.
An
fetchCol($index = 0)
Returns an entire single column of a result set as an indexed array.
Note that this method will run the result set to the end.
An
fetchAllAssoc($key, $fetch = NULL)
Returns the result set as an associative array keyed by the given field.
If the given key appears multiple times, later records will overwrite earlier ones.
An
fetchAllKeyed($key_index = 0, $value_index = 1)
Returns the entire result set as a single associative array.
This method is only useful for two-column result sets. It will return an associative array where the key is one column from the result set and the value is another field. In most cases, the default of the first two columns is appropriate.
Note that this method will run the result set to the end.
A
fetchField($index = 0)
Returns a single field from the next record of a result set.
An
fetchAssoc()
Fetches the next row and returns it as an associative array.
This method corresponds to PDOStatement::fetchObject(), but for associative arrays. For some reason PDOStatement does not have a corresponding array helper method, so one is added.
mixed
fetchObject(string $class_name = NULL, array $constructor_arguments = NULL)
Fetches the next row and returns it as an object.
The object will be of the class specified by StatementInterface::setFetchMode() or stdClass if not specified.
phpcs:disable Drupal.Commenting
The
rowCount()
Returns the number of rows affected by the last SQL statement.
setFetchMode($mode, $a1 = NULL, $a2 = [])
Sets the default fetch mode for this statement.
See http://php.net/manual/pdo.constants.php for the definition of the constants used.
A
fetch($mode = NULL, $cursor_orientation = NULL, $cursor_offset = NULL)
Fetches the next row from a result set.
See http://php.net/manual/pdo.constants.php for the definition of the constants used.
An
fetchAll($mode = NULL, $column_index = NULL, $constructor_arguments = NULL)
Returns an array containing all of the result set rows.
getIterator()
{@inheritdoc}
bool
bindColumn(mixed $column, mixed $param, int $type = 0, int $maxlen = 0, mixed $driverdata = NULL)
deprecated
deprecated
Bind a column to a PHP variable.
bool
bindParam(mixed $parameter, mixed $variable, int $data_type = \PDO::PARAM_STR, int $length = 0, mixed $driver_options = NULL)
deprecated
deprecated
Binds a parameter to the specified variable name.