Ejemplo n.º 1
0
 /**
  * 初始化字段映射数组
  *
  * @return void
  */
 private function _prepareMapHash()
 {
     $file_cache = new KISS_Util_FileCache('0' . $this->mTableHash['name']);
     if ($file_cache->checkCacheStatus()) {
         $this->mTableFieldHash = unserialize($file_cache->getCacheContent());
     } else {
         $this->mTableFieldHash = $this->SqlCommand->getTableFieldHash($this->mTableHash['name']);
         if (count($this->mTableFieldHash) > 0) {
             if (KISS_Framework_Config::getMode() == "online") {
                 //如果系统运行在online模式下,则记录缓存,默认是online模式
                 $file_cache->putCacheContent(serialize($this->mTableFieldHash));
             }
         } else {
             throw new Exception('数据库访问错误!');
         }
     }
     $keys = array_keys($this->mTableFieldHash);
     for ($i = 0; $i < count($this->mTableFieldHash); $i++) {
         $member_name = "m" . KISS_Util_Util::magicName($keys[$i]);
         $this->mMapHash[$keys[$i]] =& $this->{$member_name};
     }
     $file_cache = new KISS_Util_FileCache('1' . $this->mTableHash['name']);
     if ($file_cache->checkCacheStatus()) {
         $this->mTableHash['key'] = unserialize($file_cache->getCacheContent());
     } else {
         $this->mTableHash['key'] = $this->SqlCommand->getTablePrimeKey($this->mTableHash['name']);
         if (KISS_Framework_Config::getMode() == "online") {
             //如果系统运行在online模式下,则记录缓存,默认是online模式
             $file_cache->putCacheContent(serialize($this->mTableHash['key']));
         }
     }
 }