本文整理匯總了PHP中Lock::is_locked方法的典型用法代碼示例。如果您正苦於以下問題:PHP Lock::is_locked方法的具體用法?PHP Lock::is_locked怎麽用?PHP Lock::is_locked使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Lock
的用法示例。
在下文中一共展示了Lock::is_locked方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: release_lock
public static function release_lock($UID, $entity_type, $user)
{
// add record to lock table in order to specify that the kbit is no longer locked
// NOTE: it is recomended to implement the lock in separated class
if (Lock::is_locked($UID, $entity_type) == false) {
debugLog::log("<i>[Lock::release_lock]:</i> cannot release lock of [" . $entity_type . "]: " . $UID . " because it is not locked");
return false;
}
if (Lock::is_locked_by_user($UID, $entity_type, $user) == false) {
debugLog::log("<i>[Lock::release_lock]:</i>cannot release lock of [" . $entity_type . "]: " . $UID . " because it is not locked by the same user");
return false;
}
$dbObj = new dbAPI();
// disable lock records
$query = "UPDATE CONTENT_LOCK SET ENABLED = 0 WHERE LOCKED_UID = '" . $UID . "' AND ENTITY_TYPE = '" . $entity_type . "' AND LOCK_STATUS = 'LOCKED' AND ENABLED = 1 ";
$results = $dbObj->run_query($dbObj->db_get_contentDB(), $query);
if ($results == false) {
debugLog::log("<i>[Lock::release_lock]:</i>cannot release lock of [" . $entity_type . "]: " . $UID . " because of database update error");
return false;
}
// add release record
$query = "INSERT INTO CONTENT_LOCK (LOCKED_UID, ENTITY_TYPE, ENABLED, LOCK_STATUS, USER_ID, CREATION_DATE) VALUES (" . $UID . ", '" . $entity_type . "', 1, 'UNLOCKED', " . $user . ",'" . date("Y-m-d H:i:s") . "')";
return $dbObj->run_query($dbObj->db_get_contentDB(), $query) == true;
}