Connection::handleQueryException

protected Connection::handleQueryException(\PDOException $e, $query, array $args = array(), $options = array())

Wraps and re-throws any PDO exception thrown by static::query().

Parameters

\PDOException $e: The exception thrown by static::query().

$query: The query executed by static::query().

array $args: An array of arguments for the prepared statement.

array $options: An associative array of options to control how the query is run.

Return value

\Drupal\Core\Database\StatementInterface|int|null Most database drivers will return NULL when a PDO exception is thrown for a query, but some of them may need to re-run the query, so they can also return a \Drupal\Core\Database\StatementInterface object or an integer.

Throws

\Drupal\Core\Database\DatabaseExceptionWrapper

\Drupal\Core\Database\IntegrityConstraintViolationException

Overrides Connection::handleQueryException

File

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

Class

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

Namespace

Drupal\Core\Database\Driver\sqlite

Code

protected function handleQueryException(\PDOException $e, $query, array $args = array(), $options = array()) {
  // 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);
}
doc_Drupal
2016-10-29 08:55:51
Comments
Leave a Comment

Please login to continue.