public function AcquiaPurgeQueueEfficient::createItemMultiple in Acquia Purge 7
Add multiple items to the queue and store them efficiently.
Parameters
array $items: Non-associative array containing arrays with arbitrary data to be associated with the new tasks in the queue.
Return value
true|false TRUE if all items got created successfully, or FALSE if just one of them failed being created.
Overrides AcquiaPurgeQueueInterface::createItemMultiple
File
- lib/
queue/ AcquiaPurgeQueueEfficient.php, line 173 - Contains EfficientQueue.
Class
- AcquiaPurgeQueueEfficient
- Efficient query bundling database queue.
Code
public function createItemMultiple(array $items) {
$records = array();
// Build a array with all exactly records as they should turn into rows.
$time = time();
foreach ($items as $data) {
$records[] = array(
'name' => $this->name,
'data' => serialize($data),
'created' => $time,
);
}
// Insert all of them using just one multi-row query.
$query = db_insert('queue')
->fields(array(
'name',
'data',
'created',
));
foreach ($records as $record) {
$query
->values($record);
}
// Execute the query and finish the call.
if ($query
->execute()) {
$this
->total()
->increase(count($records));
return TRUE;
}
else {
return FALSE;
}
}