本文整理汇总了PHP中DibiConnection::begin方法的典型用法代码示例。如果您正苦于以下问题:PHP DibiConnection::begin方法的具体用法?PHP DibiConnection::begin怎么用?PHP DibiConnection::begin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DibiConnection
的用法示例。
在下文中一共展示了DibiConnection::begin方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store authorization code
* @param IAuthorizationCode $authorizationCode
* @throws InvalidScopeException
*/
public function store(IAuthorizationCode $authorizationCode)
{
$this->context->insert($this->getTable(), array('authorization_code' => $authorizationCode->getAuthorizationCode(), 'client_id' => $authorizationCode->getClientId(), 'user_id' => $authorizationCode->getUserId(), 'expires_at' => $authorizationCode->getExpires()))->execute();
$this->context->begin();
try {
foreach ($authorizationCode->getScope() as $scope) {
$this->context->insert($this->getScopeTable(), array('authorization_code' => $authorizationCode->getAuthorizationCode(), 'scope_name' => $scope))->execute();
}
} catch (\PDOException $e) {
// MySQL error 1452 - Cannot add or update a child row: a foreign key constraint fails
if (in_array(1452, $e->errorInfo)) {
throw new InvalidScopeException();
}
throw $e;
}
$this->context->commit();
}
示例2: refreshToken
/**
* @inheritDoc
*/
function refreshToken($refreshToken)
{
$this->purgeOldTokens();
$token = $this->refreshTokenToToken($refreshToken);
$this->dbConnection->begin();
// Check for existing token and lock it
$existingToken = $this->dbConnection->query('SELECT * FROM %n', $this->tableName, 'WHERE [token] = %s', $token, 'FOR UPDATE')->fetch();
// No matching token found
if ($existingToken === FALSE) {
$this->dbConnection->rollback();
return FALSE;
}
$newToken = $this->generateNewToken();
$dt = new \DateTime();
$dt->modify("+" . $this->tokenTtl . " seconds");
$this->dbConnection->query('UPDATE %n', $this->tableName, 'SET [token] = %s,', $newToken, '[expires] = %t', $dt, 'WHERE [token] = %s', $token);
$this->dbConnection->commit();
return new Token($newToken, $this->tokenTtl, $this->generateRefreshToken($newToken), $existingToken->parameters);
}
示例3: begin
/**
* Begin transaction
* @param null $savepoint
*
* @throws \DibiException
*/
public function begin($savepoint = NULL)
{
$this->database->begin($savepoint);
}
示例4: begin
/**
* Vytvoří novou transakci
* @param string $savepoint
* @throws \DibiException
*/
public function begin($savepoint = NULL)
{
$this->connection->begin($savepoint);
}