function InsertTrait::values
Same name in other branches
- 9 core/lib/Drupal/Core/Database/Query/InsertTrait.php \Drupal\Core\Database\Query\InsertTrait::values()
- 8.9.x core/lib/Drupal/Core/Database/Query/InsertTrait.php \Drupal\Core\Database\Query\InsertTrait::values()
- 10 core/lib/Drupal/Core/Database/Query/InsertTrait.php \Drupal\Core\Database\Query\InsertTrait::values()
Adds another set of values to the query to be inserted.
If $values is a numeric-keyed array, it will be assumed to be in the same order as the original fields() call. If it is associative, it may be in any order as long as the keys of the array match the names of the fields.
Parameters
array $values: An array of values to add to the query.
Return value
$this The called object.
File
-
core/
lib/ Drupal/ Core/ Database/ Query/ InsertTrait.php, line 101
Class
- InsertTrait
- Provides common functionality for INSERT and UPSERT queries.
Namespace
Drupal\Core\Database\QueryCode
public function values(array $values) {
if (is_numeric(key($values))) {
$this->insertValues[] = $values;
}
elseif ($this->insertFields) {
// Reorder the submitted values to match the fields array.
foreach ($this->insertFields as $key) {
$insert_values[$key] = $values[$key];
}
// For consistency, the values array is always numerically indexed.
$this->insertValues[] = array_values($insert_values);
}
return $this;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.