function Connection::prepareStatement
Returns a prepared statement given a SQL string.
This method caches prepared statements, reusing them when possible. It also prefixes tables names enclosed in curly braces and, optionally, quotes identifiers enclosed in square brackets.
Parameters
string $query: The query string as SQL, with curly braces surrounding the table names, and square brackets surrounding identifiers.
array $options: An associative array of options to control how the query is run. See the documentation for self::defaultOptions() for details. The content of the 'pdo' key will be passed to the prepared statement.
bool $allow_row_count: (optional) A flag indicating if row count is allowed on the statement object. Defaults to FALSE.
Return value
\Drupal\Core\Database\StatementInterface A prepared statement ready for its execute() method.
Overrides Connection::prepareStatement
1 call to Connection::prepareStatement()
- Connection::nextId in core/
modules/ sqlite/ src/ Driver/ Database/ sqlite/ Connection.php  - Retrieves a unique ID from a given sequence.
 
File
- 
              core/
modules/ sqlite/ src/ Driver/ Database/ sqlite/ Connection.php, line 412  
Class
- Connection
 - SQLite implementation of \Drupal\Core\Database\Connection.
 
Namespace
Drupal\sqlite\Driver\Database\sqliteCode
public function prepareStatement(string $query, array $options, bool $allow_row_count = FALSE) : StatementInterface {
  if (isset($options['return'])) {
    @trigger_error('Passing "return" option to ' . __METHOD__ . '() is deprecated in drupal:9.4.0 and is removed in drupal:11.0.0. For data manipulation operations, use dynamic queries instead. See https://www.drupal.org/node/3185520', E_USER_DEPRECATED);
  }
  try {
    $query = $this->preprocessStatement($query, $options);
    $statement = new Statement($this->connection, $this, $query, $options['pdo'] ?? [], $allow_row_count);
  } catch (\Exception $e) {
    $this->exceptionHandler()
      ->handleStatementException($e, $query, $options);
  }
  return $statement;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.