class 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

Expanded class hierarchy of StatementEmpty

See also

Drupal\search\SearchQuery

2 files declare their use of StatementEmpty
EmptyStatementTest.php in drupal/core/tests/Drupal/Tests/Core/Database/EmptyStatementTest.php
Definition of Drupal\system\Tests\Database\EmptyStatementTest.
SearchQuery.php in drupal/core/modules/search/lib/Drupal/search/SearchQuery.php
Definition of Drupal\search\SearchQuery.

File

drupal/core/lib/Drupal/Core/Database/StatementEmpty.php, line 23
Definition of Drupal\Core\Database\StatementEmpty

Namespace

Drupal\Core\Database
View source
class StatementEmpty implements Iterator, StatementInterface {
  public function execute($args = array(), $options = array()) {
    return FALSE;
  }
  public function getQueryString() {
    return '';
  }
  public function rowCount() {
    return 0;
  }
  public function setFetchMode($mode, $a1 = NULL, $a2 = array()) {
    return;
  }
  public function fetch($mode = NULL, $cursor_orientation = NULL, $cursor_offset = NULL) {
    return NULL;
  }
  public function fetchField($index = 0) {
    return NULL;
  }
  public function fetchObject() {
    return NULL;
  }
  public function fetchAssoc() {
    return NULL;
  }
  function fetchAll($mode = NULL, $column_index = NULL, array $constructor_arguments = array()) {
    return array();
  }
  public function fetchCol($index = 0) {
    return array();
  }
  public function fetchAllKeyed($key_index = 0, $value_index = 1) {
    return array();
  }
  public function fetchAllAssoc($key, $fetch = NULL) {
    return array();
  }

  /* Implementations of Iterator. */
  public function current() {
    return NULL;
  }
  public function key() {
    return NULL;
  }
  public function rewind() {

    // Nothing to do: our DatabaseStatement can't be rewound.
  }
  public function next() {

    // Do nothing, since this is an always-empty implementation.
  }
  public function valid() {
    return FALSE;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
StatementEmpty::current public function
StatementEmpty::execute public function Executes a prepared statement Overrides StatementInterface::execute
StatementEmpty::fetch public function
StatementEmpty::fetchAll function
StatementEmpty::fetchAllAssoc public function Returns the result set as an associative array keyed by the given field. Overrides StatementInterface::fetchAllAssoc
StatementEmpty::fetchAllKeyed public function Returns the entire result set as a single associative array. Overrides StatementInterface::fetchAllKeyed
StatementEmpty::fetchAssoc public function Fetches the next row and returns it as an associative array. Overrides StatementInterface::fetchAssoc
StatementEmpty::fetchCol public function Returns an entire single column of a result set as an indexed array. Overrides StatementInterface::fetchCol
StatementEmpty::fetchField public function Returns a single field from the next record of a result set. Overrides StatementInterface::fetchField
StatementEmpty::fetchObject public function
StatementEmpty::getQueryString public function Gets the query string of this statement. Overrides StatementInterface::getQueryString
StatementEmpty::key public function
StatementEmpty::next public function
StatementEmpty::rewind public function
StatementEmpty::rowCount public function Returns the number of rows affected by the last SQL statement. Overrides StatementInterface::rowCount
StatementEmpty::setFetchMode public function
StatementEmpty::valid public function