Statement
class Statement extends StatementPrefetch implements StatementInterface (View source)
SQLite implementation of \Drupal\Core\Database\Statement.
The PDO SQLite driver only closes SELECT statements when the PDOStatement destructor is called and SQLite does not allow data change (INSERT, UPDATE etc) on a table which has open SELECT statements. This is a user-space mock of PDOStatement that buffers all the data and doesn't have those limitations.
Properties
| protected string | $queryString | The query string. |
from StatementPrefetch |
| protected array | $driverOptions | Driver-specific options. Can be used by child classes. |
from StatementPrefetch |
| Connection | $dbh | Reference to the Drupal database connection object for this statement. |
from StatementPrefetch |
| protected PDO | $pdoConnection | Reference to the PDO connection object for this statement. |
from StatementPrefetch |
| protected array | $data | Main data store. |
from StatementPrefetch |
| protected array | $currentRow | The current row, retrieved in \PDO::FETCH_ASSOC format. |
from StatementPrefetch |
| protected int | $currentKey | The key of the current row. |
from StatementPrefetch |
| protected array | $columnNames | The list of column names in this result set. |
from StatementPrefetch |
| protected int | $rowCount | The number of rows affected by the last query. |
from StatementPrefetch |
| protected int | $resultRowCount | The number of rows in this result set. |
from StatementPrefetch |
| protected int | $fetchStyle | Holds the current fetch style (which will be used by the next fetch). |
from StatementPrefetch |
| protected array | $fetchOptions | Holds supplementary current fetch options (which will be used by the next fetch). |
from StatementPrefetch |
| protected int | $defaultFetchStyle | Holds the default fetch style. |
from StatementPrefetch |
| protected array | $defaultFetchOptions | Holds supplementary default fetch options. |
from StatementPrefetch |
| bool | $allowRowCount | Is rowCount() execution allowed. |
from StatementPrefetch |
Methods
No description
Executes a prepared statement.
Grab a PDOStatement object from a given query and its arguments.
Sets the default fetch mode for this statement.
Return the current row formatted according to the current fetch style.
Returns the number of rows affected by the last SQL statement.
Fetches the next row from a result set.
Returns a single field from the next record of a result set.
Fetches the next row and returns it as an object.
Returns an array containing all of the result set rows.
Returns an entire single column of a result set as an indexed array.
Returns the entire result set as a single associative array.
Returns the result set as an associative array keyed by the given field.
Details
__construct(PDO $pdo_connection, Connection $connection, $query, array $driver_options = [])
No description
true
execute($args = [], $options = [])
Executes a prepared statement.
protected
throwPDOException()
Throw a PDO Exception based on the last PDO error.
protected PDOStatement
getStatement($query, array|null $args = [])
Grab a PDOStatement object from a given query and its arguments.
Some drivers (including SQLite) will need to perform some preparation themselves to get the statement right.
The
getQueryString()
Gets the query string of this 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.
mixed
current()
Return the current row formatted according to the current fetch style.
This is the core method of this class. It grabs the value at the current array position in $this->data and format it according to $this->fetchStyle and $this->fetchMode.
key()
{@inheritdoc}
rewind()
{@inheritdoc}
next()
{@inheritdoc}
valid()
{@inheritdoc}
The
rowCount()
Returns the number of rows affected by the last SQL statement.
A
fetch($fetch_style = NULL, $cursor_orientation = \PDO::FETCH_ORI_NEXT, $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.
fetchColumn($index = 0)
No description
A
fetchField($index = 0)
Returns a single field from the next record of a result set.
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
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.
An
fetchAll($mode = NULL, $column_index = NULL, $constructor_arguments = NULL)
Returns an array containing all of the result set rows.
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
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.
An
fetchAllAssoc($key, $fetch_style = 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.