33 $this->name = $this->db->sanitizeString(
$name);
34 $this->workerId = $this->db->sanitizeString(md5(microtime() . getmypid()));
41 $prefix = $this->db->getTablePrefix();
42 $blob = $this->db->sanitizeString(serialize(
$item));
44 $query =
"INSERT INTO {$prefix}queue 45 SET name = '$this->name', data = '$blob', timestamp = $time";
46 return $this->db->insertData($query) !==
false;
53 $prefix = $this->db->getTablePrefix();
54 $update =
"UPDATE {$prefix}queue 55 SET worker = '$this->workerId' 56 WHERE name = '$this->name' AND worker IS NULL 57 ORDER BY id ASC LIMIT 1";
58 $num = $this->db->updateData($update,
true);
60 $select =
"SELECT data FROM {$prefix}queue 61 WHERE worker = '$this->workerId'";
62 $obj = $this->db->getDataRow($select);
64 $data = unserialize($obj->data);
65 $delete =
"DELETE FROM {$prefix}queue 66 WHERE name = '$this->name' AND worker = '$this->workerId'";
67 $this->db->deleteData($delete);
79 $prefix = $this->db->getTablePrefix();
80 $this->db->deleteData(
"DELETE FROM {$prefix}queue WHERE name = '$this->name'");
87 $prefix = $this->db->getTablePrefix();
88 $result = $this->db->getDataRow(
"SELECT COUNT(id) AS total FROM {$prefix}queue WHERE name = '$this->name'");
dequeue()
{Remove an item from the queue.mixed}
enqueue($item)
{Add an item to the queue.Item to add to queue bool}
__construct($name, Elgg_Database $db)
Create a queue.
clear()
{Clear all items from the queue.void}
size()
{Get the size of the queue.int}