Drupal's Database API, Multi-insert form

Public

Drupal's Database API, Multi-insert form

</> CopyGet raw version
php
  1. $values = array(
  2. array(
  3. 'title' => 'Example',
  4. 'uid' => 1,
  5. 'created' => REQUEST_TIME,
  6. ),
  7. array(
  8. 'title' => 'Example 2',
  9. 'uid' => 1,
  10. 'created' => REQUEST_TIME,
  11. ),
  12. array(
  13. 'title' => 'Example 3',
  14. 'uid' => 2,
  15. 'created' => REQUEST_TIME,
  16. ),
  17. );
  18. $query = db_insert('node')->fields(array('title', 'uid', 'created'));
  19. foreach ($values as $record) {
  20. $query->values($record);
  21. }
  22. $query->execute();