class StatementEmpty in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/Database/StatementEmpty.php \Drupal\Core\Database\StatementEmpty
Empty implementation of a database statement.
This class satisfies the requirements of being a database statement/result object, but does not actually contain data. It is useful when developers need to safely return an "empty" result set without connecting to an actual database. Calling code can then treat it the same as if it were an actual result set that happens to contain no records.
Hierarchy
- class \Drupal\Core\Database\StatementEmpty implements \Drupal\Core\Database\Iterator, StatementInterface
Expanded class hierarchy of StatementEmpty
See also
2 files declare their use of StatementEmpty
- EmptyStatementTest.php in core/
tests/ Drupal/ Tests/ Core/ Database/ EmptyStatementTest.php - Contains \Drupal\Tests\Core\Database\EmptyStatementTest.
- StubConnection.php in core/
tests/ Drupal/ Tests/ Core/ Database/ Stub/ StubConnection.php - Contains \Drupal\Tests\Core\Database\Stub\StubConnection.
File
- core/
lib/ Drupal/ Core/ Database/ StatementEmpty.php, line 22 - Contains \Drupal\Core\Database\StatementEmpty.
Namespace
Drupal\Core\DatabaseView source
class StatementEmpty implements \Iterator, StatementInterface {
/**
* Is rowCount() execution allowed.
*
* @var bool
*/
public $allowRowCount = FALSE;
/**
* {@inheritdoc}
*/
public function execute($args = array(), $options = array()) {
return FALSE;
}
/**
* {@inheritdoc}
*/
public function getQueryString() {
return '';
}
/**
* {@inheritdoc}
*/
public function rowCount() {
if ($this->allowRowCount) {
return 0;
}
throw new RowCountException();
}
/**
* {@inheritdoc}
*/
public function setFetchMode($mode, $a1 = NULL, $a2 = array()) {
return;
}
/**
* {@inheritdoc}
*/
public function fetch($mode = NULL, $cursor_orientation = NULL, $cursor_offset = NULL) {
return NULL;
}
/**
* {@inheritdoc}
*/
public function fetchField($index = 0) {
return NULL;
}
/**
* {@inheritdoc}
*/
public function fetchObject() {
return NULL;
}
/**
* {@inheritdoc}
*/
public function fetchAssoc() {
return NULL;
}
/**
* {@inheritdoc}
*/
public function fetchAll($mode = NULL, $column_index = NULL, $constructor_arguments = NULL) {
return array();
}
/**
* {@inheritdoc}
*/
public function fetchCol($index = 0) {
return array();
}
/**
* {@inheritdoc}
*/
public function fetchAllKeyed($key_index = 0, $value_index = 1) {
return array();
}
/**
* {@inheritdoc}
*/
public function fetchAllAssoc($key, $fetch = NULL) {
return array();
}
/**
* {@inheritdoc}
*/
public function current() {
return NULL;
}
/**
* {@inheritdoc}
*/
public function key() {
return NULL;
}
/**
* {@inheritdoc}
*/
public function rewind() {
// Nothing to do: our DatabaseStatement can't be rewound.
}
/**
* {@inheritdoc}
*/
public function next() {
// Do nothing, since this is an always-empty implementation.
}
/**
* {@inheritdoc}
*/
public function valid() {
return FALSE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
StatementEmpty:: |
public | property | Is rowCount() execution allowed. | |
StatementEmpty:: |
public | function | ||
StatementEmpty:: |
public | function |
Executes a prepared statement Overrides StatementInterface:: |
|
StatementEmpty:: |
public | function |
Fetches the next row from a result set. Overrides StatementInterface:: |
|
StatementEmpty:: |
public | function |
Returns an array containing all of the result set rows. Overrides StatementInterface:: |
|
StatementEmpty:: |
public | function |
Returns the result set as an associative array keyed by the given field. Overrides StatementInterface:: |
|
StatementEmpty:: |
public | function |
Returns the entire result set as a single associative array. Overrides StatementInterface:: |
|
StatementEmpty:: |
public | function |
Fetches the next row and returns it as an associative array. Overrides StatementInterface:: |
|
StatementEmpty:: |
public | function |
Returns an entire single column of a result set as an indexed array. Overrides StatementInterface:: |
|
StatementEmpty:: |
public | function |
Returns a single field from the next record of a result set. Overrides StatementInterface:: |
|
StatementEmpty:: |
public | function |
Fetches the next row and returns it as an object. Overrides StatementInterface:: |
|
StatementEmpty:: |
public | function |
Gets the query string of this statement. Overrides StatementInterface:: |
|
StatementEmpty:: |
public | function | ||
StatementEmpty:: |
public | function | ||
StatementEmpty:: |
public | function | ||
StatementEmpty:: |
public | function |
Returns the number of rows affected by the last SQL statement. Overrides StatementInterface:: |
|
StatementEmpty:: |
public | function |
Sets the default fetch mode for this statement. Overrides StatementInterface:: |
|
StatementEmpty:: |
public | function |