function StatementWrapperIterator::execute
Same name in other branches
- 10 core/lib/Drupal/Core/Database/StatementWrapperIterator.php \Drupal\Core\Database\StatementWrapperIterator::execute()
Overrides StatementInterface::execute
File
-
core/
lib/ Drupal/ Core/ Database/ StatementWrapperIterator.php, line 88
Class
- StatementWrapperIterator
- StatementInterface iterator implementation.
Namespace
Drupal\Core\DatabaseCode
public function execute($args = [], $options = []) {
if (isset($options['fetch'])) {
if (is_string($options['fetch'])) {
// \PDO::FETCH_PROPS_LATE tells __construct() to run before properties
// are added to the object.
$this->setFetchMode(\PDO::FETCH_CLASS | \PDO::FETCH_PROPS_LATE, $options['fetch']);
}
else {
$this->setFetchMode($options['fetch']);
}
}
if ($this->connection
->isEventEnabled(StatementExecutionStartEvent::class)) {
$startEvent = new StatementExecutionStartEvent(spl_object_id($this), $this->connection
->getKey(), $this->connection
->getTarget(), $this->getQueryString(), $args ?? [], $this->connection
->findCallerFromDebugBacktrace());
$this->connection
->dispatchEvent($startEvent);
}
try {
$return = $this->clientStatement
->execute($args);
$this->markResultsetIterable($return);
} catch (\Exception $e) {
if (isset($startEvent) && $this->connection
->isEventEnabled(StatementExecutionFailureEvent::class)) {
$this->connection
->dispatchEvent(new StatementExecutionFailureEvent($startEvent->statementObjectId, $startEvent->key, $startEvent->target, $startEvent->queryString, $startEvent->args, $startEvent->caller, $startEvent->time, get_class($e), $e->getCode(), $e->getMessage()));
}
throw $e;
}
if (isset($startEvent) && $this->connection
->isEventEnabled(StatementExecutionEndEvent::class)) {
$this->connection
->dispatchEvent(new StatementExecutionEndEvent($startEvent->statementObjectId, $startEvent->key, $startEvent->target, $startEvent->queryString, $startEvent->args, $startEvent->caller, $startEvent->time));
}
return $return;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.