3 namespace Drupal\Core\Database;
6 * Empty implementation of a database statement.
8 * This class satisfies the requirements of being a database statement/result
9 * object, but does not actually contain data. It is useful when developers
10 * need to safely return an "empty" result set without connecting to an actual
11 * database. Calling code can then treat it the same as if it were an actual
12 * result set that happens to contain no records.
14 * @see \Drupal\search\SearchQuery
16 class StatementEmpty implements \Iterator, StatementInterface {
19 * Is rowCount() execution allowed.
23 public $allowRowCount = FALSE;
28 public function execute($args = [], $options = []) {
35 public function getQueryString() {
42 public function rowCount() {
43 if ($this->allowRowCount) {
46 throw new RowCountException();
52 public function setFetchMode($mode, $a1 = NULL, $a2 = []) {
59 public function fetch($mode = NULL, $cursor_orientation = NULL, $cursor_offset = NULL) {
66 public function fetchField($index = 0) {
73 public function fetchObject() {
80 public function fetchAssoc() {
87 public function fetchAll($mode = NULL, $column_index = NULL, $constructor_arguments = NULL) {
94 public function fetchCol($index = 0) {
101 public function fetchAllKeyed($key_index = 0, $value_index = 1) {
108 public function fetchAllAssoc($key, $fetch = NULL) {
115 public function current() {
122 public function key() {
129 public function rewind() {
130 // Nothing to do: our DatabaseStatement can't be rewound.
136 public function next() {
137 // Do nothing, since this is an always-empty implementation.
143 public function valid() {