Commit 4b7a4a0e authored by zYne's avatar zYne

--no commit message

--no commit message
parent 525e7d74
...@@ -113,9 +113,10 @@ class Doctrine_Locking_Manager_Pessimistic ...@@ -113,9 +113,10 @@ class Doctrine_Locking_Manager_Pessimistic
$dbh = $this->conn->getDbh(); $dbh = $this->conn->getDbh();
$dbh->beginTransaction(); $dbh->beginTransaction();
$stmt = $dbh->prepare("INSERT INTO $this->_lockTable $stmt = $dbh->prepare('INSERT INTO ' . $this->_lockTable
(object_type, object_key, user_ident, timestamp_obtained) . ' (object_type, object_key, user_ident, timestamp_obtained)'
VALUES (:object_type, :object_key, :user_ident, :ts_obtained)"); . ' VALUES (:object_type, :object_key, :user_ident, :ts_obtained)');
$stmt->bindParam(':object_type', $objectType); $stmt->bindParam(':object_type', $objectType);
$stmt->bindParam(':object_key', $key); $stmt->bindParam(':object_key', $key);
$stmt->bindParam(':user_ident', $userIdent); $stmt->bindParam(':user_ident', $userIdent);
...@@ -130,15 +131,16 @@ class Doctrine_Locking_Manager_Pessimistic ...@@ -130,15 +131,16 @@ class Doctrine_Locking_Manager_Pessimistic
// PK violation occured => existing lock! // PK violation occured => existing lock!
} }
if (!$gotLock) { if ( ! $gotLock) {
$lockingUserIdent = $this->_getLockingUserIdent($objectType, $key); $lockingUserIdent = $this->_getLockingUserIdent($objectType, $key);
if ($lockingUserIdent !== null && $lockingUserIdent == $userIdent) { if ($lockingUserIdent !== null && $lockingUserIdent == $userIdent) {
$gotLock = true; // The requesting user already has a lock $gotLock = true; // The requesting user already has a lock
// Update timestamp // Update timestamp
$stmt = $dbh->prepare("UPDATE $this->_lockTable SET timestamp_obtained = :ts $stmt = $dbh->prepare('UPDATE ' . $this->_lockTable
WHERE object_type = :object_type AND . ' SET timestamp_obtained = :ts'
object_key = :object_key AND . ' WHERE object_type = :object_type AND'
user_ident = :user_ident"); . ' object_key = :object_key AND'
. ' user_ident = :user_ident');
$stmt->bindParam(':ts', $time); $stmt->bindParam(':ts', $time);
$stmt->bindParam(':object_type', $objectType); $stmt->bindParam(':object_type', $objectType);
$stmt->bindParam(':object_key', $key); $stmt->bindParam(':object_key', $key);
...@@ -209,9 +211,8 @@ class Doctrine_Locking_Manager_Pessimistic ...@@ -209,9 +211,8 @@ class Doctrine_Locking_Manager_Pessimistic
try { try {
$dbh = $this->conn->getDbh(); $dbh = $this->conn->getDbh();
$stmt = $dbh->prepare("SELECT user_ident $stmt = $dbh->prepare('SELECT user_ident FROM ' . $this->_lockTable
FROM $this->_lockTable . ' WHERE object_type = :object_type AND object_key = :object_key');
WHERE object_type = :object_type AND object_key = :object_key");
$stmt->bindParam(':object_type', $objectType); $stmt->bindParam(':object_type', $objectType);
$stmt->bindParam(':object_key', $key); $stmt->bindParam(':object_key', $key);
$success = $stmt->execute(); $success = $stmt->execute();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment