/** * * @access 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 { die('数据库访问错误!'); } } $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'])); } } }
/** * 构造函数 * * @param string $pTableName 表名 * @param int $pDBConfig 数据库配置偏移量 */ function __construct($pTableName, $pDBConfig = 0) { parent::__construct(); $this->mTableName = $pTableName; $this->mDBConfig = $pDBConfig; if (empty($this->mMappingTableObject) || !is_object($this->mMappingTableObject)) { $class_name = KISS_Util_Util::magicName($pTableName); if (class_exists($class_name)) { $this->mMappingTableObject = new KISS_ORM_BaseTableObjectProxy(new $class_name(), $this->mCurrentUser); } else { $this->mMappingTableObject = new KISS_ORM_BaseTableObjectProxy(new KISS_ORM_BaseTableObject($pTableName, $pDBConfig), $this->mCurrentUser); } } $this->_pageInit(); $this->_appInit(); }
/** * 构造函数 * */ public function __construct() { set_time_limit(0); array_shift($_SERVER['argv']); if (count($_SERVER['argv']) > 0) { $class_name = array_shift($_SERVER['argv']); $class_name = KISS_Util_Util::magicName($class_name, '_'); if (class_exists($class_name)) { try { parse_str(implode('&', $_SERVER['argv']), $parameters); $_GET = $parameters; $_REQUEST = $parameters; $this->_instance = new $class_name($parameters); } catch (Exception $error) { $this->showMessage($error->getMessage()); } } else { $this->showMessage('缺少类!' . $class_name); } } else { $this->showMessage('缺少参数!'); } }
private function generate() { $this->config_path = $this->mRoot . $this->mPath['config']; $registry =& KISS_Framework_Registry::instance(); $db_configs = $registry->getEntry('database_connections'); for ($i = 0; $i < count($db_configs); $i++) { $SqlCommand =& KISS_KDO_SqlCommand::getInstance($i); $tables = $SqlCommand->ExecuteArrayQuery('SHOW TABLE STATUS FROM ' . $db_configs[$i]['DatabaseName'], 0, 0, 'num'); foreach ($tables as $row) { if (is_array($_POST['tables']) && count($_POST['tables']) > 0 && in_array($row[0], $_POST['tables'])) { print "DB_{$i}: <input type='checkbox'><a href='Admin_" . KISS_Util_Util::magicName($row[0]) . ".php' target='_blank'>{$row[0]}</a> <a href='?action=config&table={$row[0]}&config={$i}'>初始化</a><br>\n"; $this->mSmarty->assign('class_name', KISS_Util_Util::magicName($row[0])); $this->mSmarty->assign('table_name', $row[0]); $this->mSmarty->assign('db_offset', $i); $this->mSmarty->assign('date', date("Y/m/d")); if (!file_exists(KISS_Framework_Config::getSystemPath('class') . "/" . KISS_Util_Util::magicName($row[0]) . "2.php")) { $ConfigFile = $this->config_path . "/{$i}_{$row[0]}.serialize"; $table_config = array(); $keys = array(); if (file_exists($ConfigFile)) { $table_config = unserialize(file_get_contents($ConfigFile)); } $SqlCommand =& KISS_KDO_SqlCommand::getInstance(); $results = $SqlCommand->ExecuteAssocArrayQuery("show full fields from `{$row['0']}`"); foreach ($results as &$field) { $field['PHPType'] = $this->getPhpType($field['Type']); $field['PHPMember'] = implode("", array_map('ucfirst', explode('_', $field['Field']))); } $this->mSmarty->assign('keys', $results); if (empty($row[1])) { $this->generate_file(KISS_Framework_Config::getSystemPath('class') . "/DB/" . KISS_Util_Util::magicName($row[0]) . ".php", $this->mSmarty->fetch("base/tpl.class.view.mapping.htm")); } else { $this->generate_file(KISS_Framework_Config::getSystemPath('class') . "/DB/" . KISS_Util_Util::magicName($row[0]) . ".php", $this->mSmarty->fetch("base/tpl.class.mapping.htm")); } } $this->generate_file($this->mRoot . $this->mPath['class'] . "/" . KISS_Util_Util::magicName($row[0]) . ".php", $this->mSmarty->fetch("base/tpl.class.manager.htm")); } } } }