Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. InsertTrait.php

function InsertTrait::useDefaults

Specifies fields for which the database defaults should be used.

If you want to force a given field to use the database-defined default, not NULL or undefined, use this method to instruct the database to use default values explicitly. In most cases this will not be necessary unless you are inserting a row that is all default values, as you cannot specify no values in an INSERT query.

Specifying a field both in fields() and in useDefaults() is an error and will not execute.

Parameters

array $fields: An array of values for which to use the default values specified in the table definition.

Return value

$this The called object.

File

core/lib/Drupal/Core/Database/Query/InsertTrait.php, line 135

Class

InsertTrait
Provides common functionality for INSERT and UPSERT queries.

Namespace

Drupal\Core\Database\Query

Code

public function useDefaults(array $fields) {
    $this->defaultFields = $fields;
    return $this;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal