public function worker() { $this->doNow(); $sql = 'SELECT * FROM ' . DelayedJob::TABLE . ' where queue="' . $this->queue . '" and run_at<= now() ' . ' and isnull(finished_at) and isnull(locked_at) and isnull(failed_at) ORDER BY priority limit 1'; $r = DB::query($sql); while (count($r)) { $this->id = $r[0]['id']; $this->queue = $r[0]['queue']; $this->attempts = $r[0]['attempts']; $this->handler = unserialize($r[0]['handler']); $this->doNow(); $r = DB::query($sql); } } //}}} //{{{queueCheck public function queueCheck() { $queue = DB::query('SELECT id FROM ' . DelayedJob::TABLE . ' where queue="' . $this->queue . '" and id<>"' . $this->id . '" and isnull(finished_at) and not isnull(locked_at) and isnull(failed_at) limit 1'); if (empty($queue)) { return true; } else { return false; } } } //end of class JobHandler error_reporting(-1); $j = new JobHandler(); $j->worker();