Skip to content

Commit

Permalink
Merge pull request #14 from evosch/patch-1
Browse files Browse the repository at this point in the history
Add support for connections
  • Loading branch information
davelip authored Feb 13, 2017
2 parents 7a09bfb + a741bb3 commit f905358
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/DatabaseQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,10 @@ public function pop($queue = null)
{
$queue = $queue ? $queue : $this->default;

DB::beginTransaction();
$query = Job::where('timestamp', '<', date('Y-m-d H:i:s', time()))
$this->database->beginTransaction();

$query = Job::on($this->database->getName() )
->where('timestamp', '<', date('Y-m-d H:i:s', time()))
->where('queue', '=', $queue)
->where(function (Builder $query) {
$query->where('status', '=', Job::STATUS_OPEN);
Expand All @@ -169,12 +171,13 @@ public function pop($queue = null)
// Mark job as started
$job->status = Job::STATUS_STARTED;
$job->save();
DB::commit();

$this->database->commit();
$dbJob = new DatabaseJob($this->container, $job, $queue);
return $dbJob;
}
else {
DB::rollback();
$this->database->rollBack();
return null;
}
}
Expand Down

0 comments on commit f905358

Please sign in to comment.