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