当前位置: 首页>>代码示例>>PHP>>正文


PHP Lock::acquire_lock方法代码示例

本文整理汇总了PHP中Lock::acquire_lock方法的典型用法代码示例。如果您正苦于以下问题:PHP Lock::acquire_lock方法的具体用法?PHP Lock::acquire_lock怎么用?PHP Lock::acquire_lock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Lock的用法示例。


在下文中一共展示了Lock::acquire_lock方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: begin_editing_Delivery

 /**
  * Disables old revisions in user database, create a copy of content records in user database then acquire lock on Delivery
  * @param  {int} $UID  The UID of the edited Delivery
  * @param  {int} $user The user that is editing the Delivery
  * @return {bool}       returns true on success false otherwise
  */
 public static function begin_editing_Delivery($UID, $user)
 {
     // acquire lock copy data records of the Delivery from the content database into user database
     // get selected Delivery
     $curr_Delivery = Delivery::get_Delivery_by_UID($UID);
     if ($curr_Delivery == null) {
         debugLog::log("<i>[delivery.php:begin_editing_Delivery]</i> Could not find Delivery of the base (" . $UID . ") in content");
         return false;
     }
     // try to acquire lock on the Delivery
     if (Lock::acquire_lock($UID, 'DELIVERY_BASE', $user) == false) {
         debugLog::log("<i>[delivery.php:begin_editing_Delivery]</i> Could not acquire lock on Delivery (" . $UID . "), check whether the Delivery is locked by other users");
         return false;
     }
     // disable all Delivery information
     Delivery::disable_all_Delivery_info($UID, 'user');
     // copy Delivery from content database into user database
     $dbObj = new dbAPI();
     $where_sttmnt = ' WHERE UID = ' . $UID . ' AND ENABLED = 1 ';
     // get columns names
     $columns_names = $dbObj->db_get_columns_names($dbObj->db_get_usersDB(), "DELIVERY_BASE", true);
     // remove primary key (auto-increment) column (id)
     $columns_names = str_replace("id,", "", $columns_names);
     // copy record from content to user
     $query = "INSERT INTO " . $dbObj->db_get_usersDB() . ".DELIVERY_BASE (" . $columns_names . ") SELECT " . $columns_names . " FROM " . $dbObj->db_get_contentDB() . ".Delivery_BASE " . $where_sttmnt . "";
     $dbObj->run_query('', $query);
     // get front Delivery table name
     $front_table_name = Delivery::get_front_table_name($curr_Delivery["FRONT_TYPE"]);
     if ($front_table_name == null) {
         debugLog::log("<i>[delivery.php:begin_editing_Delivery]</i> Could not find front Delivery table name (" . $UID . ")");
         // roll back option here
         return false;
     }
     // get columns names
     $columns_names = $dbObj->db_get_columns_names($dbObj->db_get_usersDB(), $front_table_name, true);
     // remove primary key (auto-increment) column (id)
     $columns_names = str_replace("id,", "", $columns_names);
     // copy front record from content to user
     $query = "INSERT INTO " . $dbObj->db_get_usersDB() . "." . $front_table_name . " (" . $columns_names . ") SELECT " . $columns_names . " FROM " . $dbObj->db_get_contentDB() . "." . $front_table_name . " " . $where_sttmnt . "";
     $dbObj->run_query('', $query);
     // loop over links and copy records from content to user
     $links_tables_names = Delivery::get_relations_tables_names();
     for ($i = 0; $i < count($links_tables_names); $i++) {
         // prepare where statement
         if ($links_tables_names[$i] == 'R_LD2D') {
             $where_sttmnt = ' (PARENT_ID = ' . $UID . ' OR CHILD_ID = ' . $UID . ') ';
         } else {
             $where_sttmnt = ' (DELIVERY_BASE_ID = ' . $UID . ') ';
         }
         // get columns names
         $columns_names = $dbObj->db_get_columns_names($dbObj->db_get_usersDB(), $links_tables_names[$i], true);
         // remove primary key (auto-increment) column (id)
         $columns_names = str_replace("id,", "", $columns_names);
         // get all relevant relations
         $query = "SELECT id FROM " . $links_tables_names[$i] . " where " . $where_sttmnt . " AND ENABLED = '1'";
         $relations = $dbObj->db_select_query($dbObj->db_get_contentDB(), $query);
         // loop over all records and insert them
         for ($j = 0; $j < count($relations); $j++) {
             $where_sttmnt = ' id =' . $relations[$j]["id"] . ' ';
             $query = "INSERT INTO " . $dbObj->db_get_usersDB() . "." . $links_tables_names[$i] . " (" . $columns_names . ") SELECT " . $columns_names . " FROM " . $dbObj->db_get_contentDB() . "." . $links_tables_names[$i] . " where " . $where_sttmnt . "";
             $dbObj->run_query('', $query);
         }
     }
     return true;
 }
开发者ID:radjybaba,项目名称:testserver,代码行数:71,代码来源:delivery.php


注:本文中的Lock::acquire_lock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。