1
0
mirror of synced 2025-01-18 22:41:43 +03:00
This commit is contained in:
zYne 2007-05-24 16:54:42 +00:00
parent 525e7d74a1
commit 4b7a4a0e97

View File

@ -113,9 +113,10 @@ class Doctrine_Locking_Manager_Pessimistic
$dbh = $this->conn->getDbh();
$dbh->beginTransaction();
$stmt = $dbh->prepare("INSERT INTO $this->_lockTable
(object_type, object_key, user_ident, timestamp_obtained)
VALUES (:object_type, :object_key, :user_ident, :ts_obtained)");
$stmt = $dbh->prepare('INSERT INTO ' . $this->_lockTable
. ' (object_type, object_key, user_ident, timestamp_obtained)'
. ' VALUES (:object_type, :object_key, :user_ident, :ts_obtained)');
$stmt->bindParam(':object_type', $objectType);
$stmt->bindParam(':object_key', $key);
$stmt->bindParam(':user_ident', $userIdent);
@ -130,15 +131,16 @@ class Doctrine_Locking_Manager_Pessimistic
// PK violation occured => existing lock!
}
if (!$gotLock) {
if ( ! $gotLock) {
$lockingUserIdent = $this->_getLockingUserIdent($objectType, $key);
if ($lockingUserIdent !== null && $lockingUserIdent == $userIdent) {
$gotLock = true; // The requesting user already has a lock
// Update timestamp
$stmt = $dbh->prepare("UPDATE $this->_lockTable SET timestamp_obtained = :ts
WHERE object_type = :object_type AND
object_key = :object_key AND
user_ident = :user_ident");
$stmt = $dbh->prepare('UPDATE ' . $this->_lockTable
. ' SET timestamp_obtained = :ts'
. ' WHERE object_type = :object_type AND'
. ' object_key = :object_key AND'
. ' user_ident = :user_ident');
$stmt->bindParam(':ts', $time);
$stmt->bindParam(':object_type', $objectType);
$stmt->bindParam(':object_key', $key);
@ -209,9 +211,8 @@ class Doctrine_Locking_Manager_Pessimistic
try {
$dbh = $this->conn->getDbh();
$stmt = $dbh->prepare("SELECT user_ident
FROM $this->_lockTable
WHERE object_type = :object_type AND object_key = :object_key");
$stmt = $dbh->prepare('SELECT user_ident FROM ' . $this->_lockTable
. ' WHERE object_type = :object_type AND object_key = :object_key');
$stmt->bindParam(':object_type', $objectType);
$stmt->bindParam(':object_key', $key);
$success = $stmt->execute();