Extra Block Types (EBT) - New Layout Builder experience❗

Extra Block Types (EBT) - styled, customizable block types: Slideshows, Tabs, Cards, Accordions and many others. Built-in settings for background, DOM Box, javascript plugins. Experience the future of layout building today.

Demo EBT modules Download EBT modules

❗Extra Paragraph Types (EPT) - New Paragraphs experience

Extra Paragraph Types (EPT) - analogical paragraph based set of modules.

Demo EPT modules Download EPT modules

Scroll

Drupal 8 Insert query

Drupal 8 Insert query
, by
Drupal 8 Insert query
1 answer
votes: 1371
Answer

The preferred form for most Insert queries is the compact form:

$result = $connection->insert('mytable')
  ->fields([
    'title' => 'Example',
    'uid' => 1,
    'created' => REQUEST_TIME,
  ])
  ->execute();

Degenerate form

$result = $connection->insert('mytable')
  ->fields(['title', 'uid', 'created'])
  ->values([
    'title' => 'Example',
    'uid' => 1,
    'created' => REQUEST_TIME,
  ])
  ->execute();

Drupal 8 documentation:

https://www.drupal.org/docs/8/api/database-api/insert-queries