public function Insert::execute

Same name in this branch
  1. 9.x drupal/core/lib/Drupal/Core/Database/Query/Insert.php \Drupal\Core\Database\Query\Insert::execute()
  2. 9.x drupal/core/lib/Drupal/Core/Database/Driver/mysql/Insert.php \Drupal\Core\Database\Driver\mysql\Insert::execute()
  3. 9.x drupal/core/lib/Drupal/Core/Database/Driver/sqlite/Insert.php \Drupal\Core\Database\Driver\sqlite\Insert::execute()
  4. 9.x drupal/core/lib/Drupal/Core/Database/Driver/pgsql/Insert.php \Drupal\Core\Database\Driver\pgsql\Insert::execute()

Executes the insert query.

Return value

The last insert ID of the query, if one exists. If the query was given multiple sets of values to insert, the return value is undefined. If no fields are specified, this method will do nothing and return NULL. That makes it safe to use in multi-insert loops.

Overrides Insert::execute

File

drupal/core/lib/Drupal/Core/Database/Driver/sqlite/Insert.php, line 21
Definition of Drupal\Core\Database\Driver\sqlite\Insert

Class

Insert
SQLite specific implementation of InsertQuery.

Namespace

Drupal\Core\Database\Driver\sqlite

Code

public function execute() {
  if (!$this
    ->preExecute()) {
    return NULL;
  }
  if (count($this->insertFields)) {
    return parent::execute();
  }
  else {
    return $this->connection
      ->query('INSERT INTO {' . $this->table . '} DEFAULT VALUES', array(), $this->queryOptions);
  }
}