function Statement::execute

Same name in this branch
  1. 9 core/lib/Drupal/Core/Database/Statement.php \Drupal\Core\Database\Statement::execute()
Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php \Drupal\Core\Database\Driver\sqlite\Statement::execute()
  2. 8.9.x core/lib/Drupal/Core/Database/Statement.php \Drupal\Core\Database\Statement::execute()
  3. 10 core/modules/sqlite/src/Driver/Database/sqlite/Statement.php \Drupal\sqlite\Driver\Database\sqlite\Statement::execute()
  4. 11.x core/modules/sqlite/src/Driver/Database/sqlite/Statement.php \Drupal\sqlite\Driver\Database\sqlite\Statement::execute()

Overrides StatementPrefetch::execute

File

core/modules/sqlite/src/Driver/Database/sqlite/Statement.php, line 88

Class

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

Namespace

Drupal\sqlite\Driver\Database\sqlite

Code

public function execute($args = [], $options = []) {
    try {
        $return = parent::execute($args, $options);
    } catch (\PDOException $e) {
        // 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) {
            // The schema has changed. SQLite specifies that we must resend the query.
            $return = parent::execute($args, $options);
        }
        else {
            // Rethrow the exception.
            throw $e;
        }
    }
    return $return;
}

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