Skip to content

Instantly share code, notes, and snippets.

@volgoweb
Created September 25, 2013 09:33
Show Gist options
  • Save volgoweb/6697280 to your computer and use it in GitHub Desktop.
Save volgoweb/6697280 to your computer and use it in GitHub Desktop.
Insert multiple rows into db, using drupal 7 pdo
$values = array(
array(
'title' => 'Example',
'uid' => 1,
'created' => REQUEST_TIME,
),
array(
'title' => 'Example 2',
'uid' => 1,
'created' => REQUEST_TIME,
),
array(
'title' => 'Example 3',
'uid' => 2,
'created' => REQUEST_TIME,
),
);
$query = db_insert('node')->fields(array('title', 'uid', 'created'));
foreach ($values as $record) {
$query->values($record);
}
$query->execute();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment