Skip to content

Commit

Permalink
Merge branch 'MDL-30026_sqlsrv' of git://github.com/stronk7/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
Aparup Banerjee committed Nov 23, 2011
2 parents 9d06eb1 + f8cd596 commit c32e3a0
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/dml/sqlsrv_native_moodle_database.php
Expand Up @@ -1301,7 +1301,18 @@ public function get_session_lock($rowid, $timeout) {
$timeoutmilli = $timeout * 1000; $timeoutmilli = $timeout * 1000;


$fullname = $this->dbname.'-'.$this->prefix.'-session-'.$rowid; $fullname = $this->dbname.'-'.$this->prefix.'-session-'.$rowid;
$sql = "sp_getapplock '$fullname', 'Exclusive', 'Session', $timeoutmilli"; // While this may work using proper {call sp_...} calls + binding +
// executing + consuming recordsets, the solution used for the mssql
// driver is working perfectly, so 100% mimic-ing that code.
// $sql = "sp_getapplock '$fullname', 'Exclusive', 'Session', $timeoutmilli";
$sql = "BEGIN
DECLARE @result INT
EXECUTE @result = sp_getapplock @Resource='$fullname',
@LockMode='Exclusive',
@LockOwner='Session',
@LockTimeout='$timeoutmilli'
SELECT @result
END";
$this->query_start($sql, null, SQL_QUERY_AUX); $this->query_start($sql, null, SQL_QUERY_AUX);
$result = sqlsrv_query($this->sqlsrv, $sql); $result = sqlsrv_query($this->sqlsrv, $sql);
$this->query_end($result); $this->query_end($result);
Expand Down

0 comments on commit c32e3a0

Please sign in to comment.