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


PHP I2CE_FormStorage::releaseStorage方法代码示例

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


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

示例1: slowPopulate

 /**
  * Method used to populate the cache table in case the form storage mechanism is not DB like
  * @param boolean $check_mod.  Defaults to true.  If false, it skips the mod time check
  */
 protected function slowPopulate($check_mod = true, $id = null)
 {
     $fields = array();
     $mdb2_types = array();
     $default_values = array();
     foreach ($this->formObj as $field => $fieldObj) {
         if (!$fieldObj->isInDB()) {
             continue;
         }
         $fields[] = $field;
         $mdb2_types[] = $fieldObj->getMDB2Type();
         $default_values[$field] = $fieldObj->getDBValue();
     }
     $default_values['last_modified'] = '1900-01-01 00:00:00';
     $default_values['created'] = '0000-00-00 00:00:00';
     $default_values['parent'] = '|';
     $insert_fields = $fields;
     $insert_fields[] = 'last_modified';
     $insert_fields[] = 'created';
     $fields[] = 'last_modified';
     $fields[] = 'created';
     $fields[] = 'parent';
     $insert_fields[] = 'parent';
     $insert_fields[] = "id";
     $update_fields = array();
     foreach ($insert_fields as &$field) {
         $field = '`' . $field . '`';
         $update_fields[] = "{$field}=values({$field})";
     }
     unset($field);
     $insertQry = 'INSERT INTO ' . $this->table_name . " (" . implode(',', $insert_fields) . " ) " . " VALUES (" . implode(',', array_fill(0, count($insert_fields), '?')) . ")" . " ON DUPLICATE KEY UPDATE " . implode(',', $update_fields);
     if (I2CE_CachedForm::$spam) {
         I2CE::raiseError("Slow populate:\n{$insertQry}");
     }
     $db = MDB2::singleton();
     $prep = $db->prepare($insertQry, $mdb2_types, MDB2_PREPARE_MANIP);
     if (I2CE::pearError($prep, "Error setting up form in the database:")) {
         return false;
     }
     if ($check_mod) {
         $mod_time = $this->getLastCachedTime();
     } else {
         $mod_time = -1;
     }
     $storage = I2CE_FormStorage::getStorageMechanism($this->form);
     if (!$storage instanceof I2CE_FormStorage_Mechanism) {
         I2CE::raiseError("form {$form} does not have valid form storage mechanism");
         return false;
     }
     if (I2CE_CachedForm::$spam) {
         I2CE::raiseError("Mod Time ={$mod_time}");
     }
     if ($id !== null) {
         $ids = array($id);
     } else {
         $ids = $storage->getRecords($this->form, $mod_time);
     }
     if (I2CE_CachedForm::$spam) {
         I2CE::raiseError(implode("\n", $ids));
     }
     foreach ($ids as $id) {
         $data = $storage->lookupField($this->form, $id, $fields, false);
         if (!is_array($data)) {
             continue;
         }
         $t_data = array();
         foreach ($fields as $field) {
             if (array_key_exists($field, $data)) {
                 $t_data[] = $data[$field];
             } else {
                 $t_data[] = $default_values[$field];
             }
         }
         $t_data[] = $this->form . "|" . $id;
         $res = $prep->execute($t_data);
         if (I2CE::pearError($res, "Error insert into cache table:")) {
             return false;
         }
     }
     I2CE_FormStorage::releaseStorage($this->form);
     if (I2CE_CachedForm::$spam) {
         I2CE::raiseError("Populated " . count($ids) . " entries for {$this->form}");
     }
     return true;
 }
开发者ID:apelon-ohie,项目名称:ihris-site,代码行数:89,代码来源:I2CE_CachedForm.php


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