beginTransaction() public méthode

Start a new database transaction.
public beginTransaction ( ) : void
Résultat void
 /**
  * Save multiple notifications sent
  * at once.
  *
  * @param  array $notifications
  * @return mixed
  */
 public function storeMultiple(array $notifications)
 {
     $this->db->beginTransaction();
     $stackId = $this->db->table($this->notification->getTable())->max('stack_id') + 1;
     foreach ($notifications as $key => $notification) {
         $notifications[$key]['stack_id'] = $stackId;
     }
     $insert = $this->db->table($this->notification->getTable())->insert($notifications);
     $this->db->commit();
     return $insert;
 }
 /**
  * @param mixed $id
  * @param DomainEventStream $eventStream
  */
 public function append($id, DomainEventStream $eventStream)
 {
     $id = (string) $id;
     //Used to thrown errors if ID will not cast to string
     $this->db->beginTransaction();
     try {
         foreach ($eventStream as $domainMessage) {
             $this->insertEvent($domainMessage);
         }
         $this->db->commit();
     } catch (QueryException $ex) {
         $this->db->rollBack();
         throw $ex;
     }
 }
 /**
  * Delete a reserved job from the queue.
  *
  * @param  string  $queue
  * @param  string  $id
  * @return void
  */
 public function deleteReserved($queue, $id)
 {
     $this->database->beginTransaction();
     if ($this->database->table($this->table)->lockForUpdate()->find($id)) {
         $this->database->table($this->table)->where('id', $id)->delete();
     }
     $this->database->commit();
 }
Exemple #4
0
 /**
  * Get the next available job for the queue.
  *
  * @param string|null $queue        	
  * @return \StdClass|null
  */
 protected function getNextAvailableJob($queue)
 {
     $this->database->beginTransaction();
     $job = $this->database->table($this->table)->lockForUpdate()->where('queue', $this->getQueue($queue))->where('reserved', 0)->where('available_at', '<=', $this->getTime())->orderBy('id', 'asc')->first();
     return $job ? (object) $job : null;
 }
 /**
  * Database 연길 할 때 transaction 이 진행 중이라면 연결하려는 $connection 의 transaction 시작
  * \Illuminiate\Database\Connection 의 transaction level 은 0 또는 1 로 제한.
  * transaction level 은 transaction handler 로 제어.
  *
  * @param Connection $connection connection
  * @return void
  */
 public function setCurrent(Connection $connection)
 {
     if ($this->transactionLevel() > 0 && $connection->transactionLevel() === 0) {
         $connection->beginTransaction();
     }
 }