function Statement::execute
Same name in this branch
- 11.x core/modules/sqlite/src/Driver/Database/sqlite/Statement.php \Drupal\sqlite\Driver\Database\sqlite\Statement::execute()
Same name and namespace in other branches
- 9 core/modules/sqlite/src/Driver/Database/sqlite/Statement.php \Drupal\sqlite\Driver\Database\sqlite\Statement::execute()
- 9 core/lib/Drupal/Core/Database/Statement.php \Drupal\Core\Database\Statement::execute()
- 8.9.x core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php \Drupal\Core\Database\Driver\sqlite\Statement::execute()
- 8.9.x core/lib/Drupal/Core/Database/Statement.php \Drupal\Core\Database\Statement::execute()
- 10 core/modules/sqlite/src/Driver/Database/sqlite/Statement.php \Drupal\sqlite\Driver\Database\sqlite\Statement::execute()
Overrides StatementBase::execute
File
-
core/
modules/ mysqli/ src/ Driver/ Database/ mysqli/ Statement.php, line 71
Class
- Statement
- MySQLi implementation of \Drupal\Core\Database\Query\StatementInterface.
Namespace
Drupal\mysqli\Driver\Database\mysqliCode
public function execute($args = [], $options = []) {
if (isset($options['fetch'])) {
if (is_string($options['fetch'])) {
$this->setFetchMode(FetchAs::ClassObject, $options['fetch']);
}
else {
if (is_int($options['fetch'])) {
@trigger_error("Passing the 'fetch' key as an integer to \$options in execute() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use a case of \\Drupal\\Core\\Database\\Statement\\FetchAs enum instead. See https://www.drupal.org/node/3488338", E_USER_DEPRECATED);
}
$this->setFetchMode($options['fetch']);
}
}
$startEvent = $this->dispatchStatementExecutionStartEvent($args ?? []);
try {
// Prepare the lower-level statement if it's not been prepared already.
if (!$this->hasClientStatement()) {
// Replace named placeholders with positional ones if needed.
$this->paramsPositions = array_flip(array_keys($args));
$converter = new NamedPlaceholderConverter();
$converter->parse($this->queryString, $args);
[
$convertedQueryString,
$args,
] = [
$converter->getConvertedSQL(),
$converter->getConvertedParameters(),
];
$this->clientStatement = $this->clientConnection
->prepare($convertedQueryString);
}
else {
// Transform the $args to positional.
$tmp = [];
foreach ($this->paramsPositions as $param => $pos) {
$tmp[$pos] = $args[$param];
}
$args = $tmp;
}
// In mysqli, the results of the statement execution are returned in a
// different object than the statement itself.
$return = $this->getClientStatement()
->execute($args);
$this->result = new Result($this->fetchMode, $this->fetchOptions, $this->getClientStatement()
->get_result(), $this->clientConnection);
$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.