本文整理汇总了PHP中Illuminate\Database\Connection::beginTransaction方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::beginTransaction方法的具体用法?PHP Connection::beginTransaction怎么用?PHP Connection::beginTransaction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Connection
的用法示例。
在下文中一共展示了Connection::beginTransaction方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: storeMultiple
/**
* 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;
}
示例2: append
/**
* @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;
}
}
示例3: deleteReserved
/**
* 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();
}
示例4: getNextAvailableJob
/**
* 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;
}
示例5: setCurrent
/**
* 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();
}
}