protected function queueNext() { $time = time(); $sql = "SELECT rowid, base, send_time FROM queue WHERE send_time>0 ORDER BY send_time, rowid LIMIT 1"; if ($data = $this->db->query($sql)->fetchAll(PDO::FETCH_ASSOC)) { $data = $data[0]; if ($data['send_time'] <= $time) { $sql = "UPDATE queue SET send_time=0\n WHERE rowid={$data['rowid']} AND send_time>0"; if ($this->db->exec($sql)) { tool_url::touch("{$data['base']}queue/pMail/{$data['rowid']}/" . $this->getToken()); } } else { pTask::schedule(new pTask(array($this, 'control')), $data['send_time']); } } }
protected function queueNext() { $time = time(); $sql = "SELECT rowid, base, run_time FROM queue WHERE run_time>0 ORDER BY run_time, rowid LIMIT 1"; if ($data = $this->db->query($sql)->fetchAll(PDO::FETCH_ASSOC)) { $data = $data[0]; 0 > $this->maxage && ($this->maxage = $CONFIG['maxage']); if ($data['run_time'] <= $time) { $sql = "UPDATE queue SET run_time=0\n WHERE rowid={$data['rowid']} AND run_time>0"; if ($this->db->exec($sql)) { tool_url::touch("{$data['base']}queue/pTask/{$data['rowid']}/" . $this->getToken()); } $sql = "SELECT run_time FROM queue WHERE run_time>{$time} ORDER BY run_time LIMIT 1"; if ($data = $this->db->query($sql)->fetchAll(PDO::FETCH_NUM)) { p::setMaxage(min($this->maxage, $data[0][0] - $time)); } } else { p::setMaxage(min($this->maxage, $data['run_time'] - $time)); } } }
function startQueue($q = false) { $q || ($q = $this->getQueueDefinition()); $this->isRunning($q) || tool_url::touch($q->url); }