本文整理匯總了PHP中Doctrine\DBAL\Platforms\AbstractPlatform::getWriteLockSql方法的典型用法代碼示例。如果您正苦於以下問題:PHP AbstractPlatform::getWriteLockSql方法的具體用法?PHP AbstractPlatform::getWriteLockSql怎麽用?PHP AbstractPlatform::getWriteLockSql使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Doctrine\DBAL\Platforms\AbstractPlatform
的用法示例。
在下文中一共展示了AbstractPlatform::getWriteLockSql方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: lock
/**
* Lock all rows of this entity matching the given criteria with the specified pessimistic lock mode
*
* @param array $criteria
* @param int $lockMode
* @return void
*/
public function lock(array $criteria, $lockMode)
{
$conditionSql = $this->_getSelectConditionSQL($criteria);
if ($lockMode == LockMode::PESSIMISTIC_READ) {
$lockSql = $this->_platform->getReadLockSql();
} else {
if ($lockMode == LockMode::PESSIMISTIC_WRITE) {
$lockSql = $this->_platform->getWriteLockSql();
}
}
$sql = 'SELECT 1 ' . $this->_platform->appendLockHint($this->getLockTablesSql(), $lockMode) . ($conditionSql ? ' WHERE ' . $conditionSql : '') . ' ' . $lockSql;
list($params, $types) = $this->expandParameters($criteria);
$stmt = $this->_conn->executeQuery($sql, $params, $types);
}
示例2: lock
/**
* Locks all rows of this entity matching the given criteria with the specified pessimistic lock mode.
*
* @param array $criteria
* @param int $lockMode
*
* @return void
*/
public function lock(array $criteria, $lockMode)
{
$lockSql = '';
$conditionSql = $this->getSelectConditionSQL($criteria);
switch ($lockMode) {
case LockMode::PESSIMISTIC_READ:
$lockSql = $this->platform->getReadLockSql();
break;
case LockMode::PESSIMISTIC_WRITE:
$lockSql = $this->platform->getWriteLockSql();
break;
}
$lock = $this->platform->appendLockHint($this->getLockTablesSql(), $lockMode);
$where = ($conditionSql ? ' WHERE ' . $conditionSql : '') . ' ';
$sql = 'SELECT 1 '
. $lock
. $where
. $lockSql;
list($params, $types) = $this->expandParameters($criteria);
$this->conn->executeQuery($sql, $params, $types);
}