function Insert::execute
Same name in this branch
- 11.x core/modules/sqlite/src/Driver/Database/sqlite/Insert.php \Drupal\sqlite\Driver\Database\sqlite\Insert::execute()
- 11.x core/modules/pgsql/src/Driver/Database/pgsql/Insert.php \Drupal\pgsql\Driver\Database\pgsql\Insert::execute()
- 11.x core/lib/Drupal/Core/Database/Query/Insert.php \Drupal\Core\Database\Query\Insert::execute()
Same name in other branches
- 9 core/modules/sqlite/src/Driver/Database/sqlite/Insert.php \Drupal\sqlite\Driver\Database\sqlite\Insert::execute()
- 9 core/modules/mysql/src/Driver/Database/mysql/Insert.php \Drupal\mysql\Driver\Database\mysql\Insert::execute()
- 9 core/modules/pgsql/src/Driver/Database/pgsql/Insert.php \Drupal\pgsql\Driver\Database\pgsql\Insert::execute()
- 9 core/lib/Drupal/Core/Database/Query/Insert.php \Drupal\Core\Database\Query\Insert::execute()
- 8.9.x core/lib/Drupal/Core/Database/Driver/sqlite/Insert.php \Drupal\Core\Database\Driver\sqlite\Insert::execute()
- 8.9.x core/lib/Drupal/Core/Database/Driver/mysql/Insert.php \Drupal\Core\Database\Driver\mysql\Insert::execute()
- 8.9.x core/lib/Drupal/Core/Database/Driver/pgsql/Insert.php \Drupal\Core\Database\Driver\pgsql\Insert::execute()
- 8.9.x core/lib/Drupal/Core/Database/Query/Insert.php \Drupal\Core\Database\Query\Insert::execute()
- 10 core/modules/sqlite/src/Driver/Database/sqlite/Insert.php \Drupal\sqlite\Driver\Database\sqlite\Insert::execute()
- 10 core/modules/mysql/src/Driver/Database/mysql/Insert.php \Drupal\mysql\Driver\Database\mysql\Insert::execute()
- 10 core/modules/pgsql/src/Driver/Database/pgsql/Insert.php \Drupal\pgsql\Driver\Database\pgsql\Insert::execute()
- 10 core/lib/Drupal/Core/Database/Query/Insert.php \Drupal\Core\Database\Query\Insert::execute()
Overrides Insert::execute
File
-
core/
modules/ mysql/ src/ Driver/ Database/ mysql/ Insert.php, line 12
Class
- Insert
- MySQL implementation of \Drupal\Core\Database\Query\Insert.
Namespace
Drupal\mysql\Driver\Database\mysqlCode
public function execute() {
if (!$this->preExecute()) {
return NULL;
}
// If we're selecting from a SelectQuery, finish building the query and
// pass it back, as any remaining options are irrelevant.
if (empty($this->fromQuery)) {
$max_placeholder = 0;
$values = [];
foreach ($this->insertValues as $insert_values) {
foreach ($insert_values as $value) {
$values[':db_insert_placeholder_' . $max_placeholder++] = $value;
}
}
}
else {
$values = $this->fromQuery
->getArguments();
}
$stmt = $this->connection
->prepareStatement((string) $this, $this->queryOptions);
try {
$stmt->execute($values, $this->queryOptions);
$last_insert_id = $this->connection
->lastInsertId();
} catch (\Exception $e) {
$this->connection
->exceptionHandler()
->handleExecutionException($e, $stmt, $values, $this->queryOptions);
}
// Re-initialize the values array so that we can re-use this query.
$this->insertValues = [];
return $last_insert_id;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.