예제 #1
0
 /**
  * Release the global database lock
  **/
 private static function release_lock()
 {
     global $DB;
     if (self::$lockname) {
         $DB->releaseLock(self::$lockname);
         self::$lockname = '';
     }
 }
예제 #2
0
 /**
  * Get a global database lock
  **/
 private static function get_lock()
 {
     global $DB;
     // Changer de nom toutes les heures en cas de blocage MySQL (ca arrive)
     $nom = $DB->dbdefault . ".glpicron." . intval(time() / HOUR_TIMESTAMP - 340000);
     $nom = addslashes($nom);
     $query = "SELECT GET_LOCK('{$nom}', 0)";
     $result = $DB->query($query);
     list($lock_ok) = $DB->fetch_array($result);
     if ($lock_ok) {
         self::$lockname = $nom;
     }
     return $lock_ok;
 }