function Connection::handleQueryException

Same name in this branch
  1. 8.9.x core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::handleQueryException()
Same name in other branches
  1. 9 core/modules/sqlite/src/Driver/Database/sqlite/Connection.php \Drupal\sqlite\Driver\Database\sqlite\Connection::handleQueryException()
  2. 9 core/modules/mysql/src/Driver/Database/mysql/Connection.php \Drupal\mysql\Driver\Database\mysql\Connection::handleQueryException()
  3. 9 core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::handleQueryException()

Overrides Connection::handleQueryException

File

core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php, line 340

Class

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

Namespace

Drupal\Core\Database\Driver\sqlite

Code

protected function handleQueryException(\PDOException $e, $query, array $args = [], $options = []) {
    // The database schema might be changed by another process in between the
    // time that the statement was prepared and the time the statement was run
    // (e.g. usually happens when running tests). In this case, we need to
    // re-run the query.
    // @see http://www.sqlite.org/faq.html#q15
    // @see http://www.sqlite.org/rescode.html#schema
    if (!empty($e->errorInfo[1]) && $e->errorInfo[1] === 17) {
        return $this->query($query, $args, $options);
    }
    parent::handleQueryException($e, $query, $args, $options);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.