function Connection::prepareStatement

Same name in this branch
  1. 11.x core/modules/pgsql/src/Driver/Database/pgsql/Connection.php \Drupal\pgsql\Driver\Database\pgsql\Connection::prepareStatement()
  2. 11.x core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::prepareStatement()
Same name in other branches
  1. 9 core/modules/sqlite/src/Driver/Database/sqlite/Connection.php \Drupal\sqlite\Driver\Database\sqlite\Connection::prepareStatement()
  2. 9 core/modules/pgsql/src/Driver/Database/pgsql/Connection.php \Drupal\pgsql\Driver\Database\pgsql\Connection::prepareStatement()
  3. 9 core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::prepareStatement()
  4. 10 core/modules/sqlite/src/Driver/Database/sqlite/Connection.php \Drupal\sqlite\Driver\Database\sqlite\Connection::prepareStatement()
  5. 10 core/modules/pgsql/src/Driver/Database/pgsql/Connection.php \Drupal\pgsql\Driver\Database\pgsql\Connection::prepareStatement()
  6. 10 core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::prepareStatement()

Overrides Connection::prepareStatement

File

core/modules/sqlite/src/Driver/Database/sqlite/Connection.php, line 415

Class

Connection
SQLite implementation of \Drupal\Core\Database\Connection.

Namespace

Drupal\sqlite\Driver\Database\sqlite

Code

public function prepareStatement(string $query, array $options, bool $allow_row_count = FALSE) : StatementInterface {
    assert(!isset($options['return']), 'Passing "return" option to prepareStatement() has no effect. See https://www.drupal.org/node/3185520');
    if (isset($options['fetch']) && is_int($options['fetch'])) {
        @trigger_error("Passing the 'fetch' key as an integer to \$options in prepareStatement() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use a case of \\Drupal\\Core\\Database\\FetchAs enum instead. See https://www.drupal.org/node/3488338", 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.