3 namespace Drupal\Core\Database;
7 * Empty implementation of a database statement.
9 * This class satisfies the requirements of being a database statement/result
10 * object, but does not actually contain data. It is useful when developers
11 * need to safely return an "empty" result set without connecting to an actual
12 * database. Calling code can then treat it the same as if it were an actual
13 * result set that happens to contain no records.
15 * @see \Drupal\search\SearchQuery
17 class StatementEmpty implements \Iterator, StatementInterface {
20 * Is rowCount() execution allowed.
24 public $allowRowCount = FALSE;
29 public function execute($args = [], $options = []) {
36 public function getQueryString() {
43 public function rowCount() {
44 if ($this->allowRowCount) {
47 throw new RowCountException();
53 public function setFetchMode($mode, $a1 = NULL, $a2 = []) {
60 public function fetch($mode = NULL, $cursor_orientation = NULL, $cursor_offset = NULL) {
67 public function fetchField($index = 0) {
74 public function fetchObject() {
81 public function fetchAssoc() {
88 public function fetchAll($mode = NULL, $column_index = NULL, $constructor_arguments = NULL) {
95 public function fetchCol($index = 0) {
102 public function fetchAllKeyed($key_index = 0, $value_index = 1) {
109 public function fetchAllAssoc($key, $fetch = NULL) {
116 public function current() {
123 public function key() {
130 public function rewind() {
131 // Nothing to do: our DatabaseStatement can't be rewound.
137 public function next() {
138 // Do nothing, since this is an always-empty implementation.
144 public function valid() {