add function to check for a lock

This commit is contained in:
Clint Armstrong
2015-07-22 07:58:36 -04:00
parent 86e0f42dc7
commit 777d5d6c6f
2 changed files with 13 additions and 11 deletions

View File

@ -60,12 +60,12 @@ function dbQuery($sql, $parameters=array()) {
/*
* Aquire a lock on a string
* Check a lock on a string
* */
function dbGetLock($data, $timeout = 0) {
$sql = 'SELECT GET_LOCK(\'' . $data . '\',' . $timeout . ')';
$result = dbFetchCell($sql);
return $result;
function dbCheckLock($data, $timeout = 0) {
$sql = 'SELECT IS_FREE_LOCK(\'' . $data . '\')';
$result = dbFetchCell($sql);
return $result;
}
@ -76,8 +76,9 @@ function dbReleaseLock($data, $timeout = 0) {
$sql = 'SELECT RELEASE_LOCK(\'' . $data . '\')';
$result = dbFetchCell($sql);
return $result;
}
/*
* Passed an array and a table name, it attempts to insert the data into the table.
* Check for boolean false to determine whether insert failed

View File

@ -60,12 +60,12 @@ function dbQuery($sql, $parameters=array()) {
/*
* Aquire a lock on a string
* Check a lock on a string
* */
function dbGetLock($data, $timeout = 0) {
$sql = 'SELECT GET_LOCK(\'' . $data . '\',' . $timeout . ')';
$result = dbFetchCell($sql);
return $result;
function dbCheckLock($data, $timeout = 0) {
$sql = 'SELECT IS_FREE_LOCK(\'' . $data . '\')';
$result = dbFetchCell($sql);
return $result;
}
@ -76,6 +76,7 @@ function dbReleaseLock($data, $timeout = 0) {
$sql = 'SELECT RELEASE_LOCK(\'' . $data . '\')';
$result = dbFetchCell($sql);
return $result;
}
/*