本文整理汇总了PHP中OCP\IDBConnection::lockTable方法的典型用法代码示例。如果您正苦于以下问题:PHP IDBConnection::lockTable方法的具体用法?PHP IDBConnection::lockTable怎么用?PHP IDBConnection::lockTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCP\IDBConnection
的用法示例。
在下文中一共展示了IDBConnection::lockTable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getNext
/**
* get the next job in the list
*
* @return IJob|null
*/
public function getNext()
{
$query = $this->connection->getQueryBuilder();
$query->select('*')->from('jobs')->where($query->expr()->lte('reserved_at', $query->createNamedParameter($this->timeFactory->getTime() - 12 * 3600, IQueryBuilder::PARAM_INT)))->orderBy('last_checked', 'ASC')->setMaxResults(1);
$update = $this->connection->getQueryBuilder();
$update->update('jobs')->set('reserved_at', $update->createNamedParameter($this->timeFactory->getTime()))->set('last_checked', $update->createNamedParameter($this->timeFactory->getTime()))->where($update->expr()->eq('id', $update->createParameter('jobid')));
$this->connection->lockTable('jobs');
$result = $query->execute();
$row = $result->fetch();
$result->closeCursor();
if ($row) {
$update->setParameter('jobid', $row['id']);
$update->execute();
$this->connection->unlockTable();
$job = $this->buildJob($row);
if ($job === null) {
// Background job from disabled app, try again.
return $this->getNext();
}
return $job;
} else {
$this->connection->unlockTable();
return null;
}
}
示例2: lockTable
/**
* @inheritdoc
*/
public function lockTable($tableName)
{
$this->connection->lockTable($tableName);
}