function StatementWrapperIterator::execute
Same name and namespace in other branches
- 11.x core/lib/Drupal/Core/Database/StatementWrapperIterator.php \Drupal\Core\Database\StatementWrapperIterator::execute()
- 10 core/lib/Drupal/Core/Database/StatementWrapperIterator.php \Drupal\Core\Database\StatementWrapperIterator::execute()
Overrides StatementBase::execute
File
-
core/
lib/ Drupal/ Core/ Database/ StatementWrapperIterator.php, line 65
Class
- StatementWrapperIterator
- StatementInterface iterator implementation.
Namespace
Drupal\Core\DatabaseCode
public function execute($args = [], $options = []) {
assert(!isset($options['fetch']) || $options['fetch'] instanceof FetchAs || is_string($options['fetch']), 'The "fetch" option passed to execute() must contain a FetchAs enum case or a string. See https://www.drupal.org/node/3488338');
if (isset($options['fetch'])) {
if (is_string($options['fetch'])) {
$this->setFetchMode(FetchAs::ClassObject, $options['fetch']);
}
else {
$this->setFetchMode($options['fetch']);
}
}
$startEvent = $this->dispatchStatementExecutionStartEvent($args ?? []);
try {
$return = $this->clientExecute($args, $options);
$this->result = new PdoResult($this->fetchMode, $this->fetchOptions, $this->getClientStatement());
$this->markResultsetIterable($return);
} catch (\Exception $e) {
$this->dispatchStatementExecutionFailureEvent($startEvent, $e);
throw $e;
}
$this->dispatchStatementExecutionEndEvent($startEvent);
return $return;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.