本文整理汇总了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;
}