示例#1
0
 /**
  *
  * @param string $pTableName 数据库表名
  * @param int $pDBConfig 数据库连接配置文件中配置ID
  * @access public
  */
 function __construct($pTableName, $pDBConfig = 0)
 {
     parent::__construct();
     $this->SqlCommand =& KISS_KDO_SqlCommand::getInstance($pDBConfig);
     $this->mTableHash = array('name' => $pTableName);
     $this->prepareMapHash();
 }
示例#2
0
 /**
  * 得到符合条件的记录总数
  *
  * @param int    $pSmartCode 是否精确匹配,1为模糊(默认),0为精确
  * @param string $pColumns   需要提取的字段
  * @param string $pGroupBy   需要合并的字段
  *
  * @return int
  */
 public function _count($pSmartCode = 1, $pColumns = '*', $pGroupBy = '')
 {
     $this->_generateSql('', $pSmartCode, $pColumns, $pGroupBy);
     if (KISS_Framework_Config::isCached()) {
         $return = $this->SqlCommand->ExecuteCacheArrayQuery($this->mLastCountSQLQuery, 0, 10, 'num', array($this->mTableHash['name']));
     } else {
         $return = $this->SqlCommand->ExecuteArrayQuery($this->mLastCountSQLQuery, 0, 10, 'num');
     }
     return $return[0][0];
 }
示例#3
0
 private function config()
 {
     $config_path = $this->mRoot . $this->mPath['config'];
     parent::__construct();
     if (isset($_GET['table']) && isset($_GET['config'])) {
         $config_file = $config_path . "/{$_GET['config']}_{$_GET['table']}.serialize";
         if (!file_exists($config_file)) {
             $SqlCommand =& KISS_KDO_SqlCommand::getInstance(intval($_GET['config']));
             $fields = $SqlCommand->ExecuteArrayQuery("show full fields from `{$_GET['table']}`");
             foreach ($fields as $row) {
                 $config[] = array('name' => $row['Field'], 'comment' => $row['Comment'], 'type' => 'text', 'insert' => '1', 'update' => '1', 'select' => '1', 'list' => '1', 'search' => '1');
             }
             /*var_dump($fields);
             
                     $this->mMappingTableObject = new BaseTableObject($_GET['table'],$_GET['config']);
                     foreach($this->mMappingTableObject->mMapHash as $key => $value) {
                     $config[] = array (    'name' => $key,'comment' => $key,'type' => 'text','insert' => '1','update' => '1','select' => '1','list' => '1','search' => '1');
                     }*/
             file_put_contents($config_file, serialize($config));
         }
         if ($_SERVER['REQUEST_METHOD'] == "POST") {
             file_put_contents($config_file, serialize($_POST['table_config']));
         }
         $table_config = unserialize(file_get_contents($config_file));
         $this->mSmarty->assign('list', $table_config);
         $this->mSmarty->assign('_action', 'config');
         $this->mSmarty->assign('types', array('text' => '单行文本', 'textarea' => '多行文本', 'file' => '文件', 'password' => '密码', 'select' => '列表', 'date' => '日期'));
         $this->mSmarty->assign('yesno', array('1' => '是', '0' => '否'));
         $this->mSmarty->display("tpl.config.htm");
     } else {
         die("没有指定表名");
     }
 }
示例#4
0
 /**
  * 程序初始化,检测模板和配置文件
  *
  * @return void
  */
 private function _appInit()
 {
     $this->generateTemplate();
     if (!file_exists(KISS_Framework_Config::getSystemPath('template') . "/{$this->mTemplateFile}")) {
         $config_file = KISS_Framework_Config::getSystemPath('temp') . "/config/{$this->mDBConfig}_{$this->mTableName}.serialize";
         if (!file_exists($config_file)) {
             /*foreach ($this->mMappingTableObject as $key => $value) {
               $config[] = array (    'name' => $key, 'comment' => $key, 'type' => 'text', 'insert' => '1', 'update' => '1', 'select' => '1', 'list' => '1', 'search' => '1');
               }*/
             $SqlCommand =& KISS_KDO_SqlCommand::getInstance($this->mDBConfig);
             $fields = $SqlCommand->ExecuteArrayQuery("show full fields from `{$this->mTableName}`");
             foreach ($fields as $row) {
                 $config[] = array('name' => $row['Field'], 'comment' => $row['Comment'], 'type' => 'text', 'insert' => '1', 'update' => '1', 'select' => '1', 'list' => '1', 'search' => '1');
             }
             file_put_contents($config_file, serialize($config));
         }
         $table_config = unserialize(file_get_contents($config_file));
         $template_c_path = KISS_Framework_Config::getSystemPath('temp') . '/template_c';
         $smarty = new Smarty();
         $smarty->template_dir = dirname(dirname(__FILE__)) . '/Tools/Builder/template/';
         $smarty->compile_dir = $template_c_path;
         $smarty->config_dir = $template_c_path;
         $smarty->cache_dir = $template_c_path;
         foreach ($table_config as $config) {
             $config['file'] = "base/tpl.input.{$config['type']}.{$this->mAction}.htm";
             if (!file_exists(KISS_Framework_Config::getSystemPath('template') . "/{$config['file']}")) {
                 $config['file'] = "base/tpl.input.{$config['type']}.htm";
             }
             $table_configs[] = $config;
         }
         $smarty->assign('action_template', "base/tpl.base_{$this->mAction}.htm");
         $smarty->assign('config', $table_configs);
         $smarty->assign("_action", $this->mAction);
         $smarty->assign("_table", $this->mTableName);
         $smarty->assign('key', $this->mMappingTableObject->mTableHash['key']);
         $output = $smarty->fetch("base/tpl.BaseTableAdmin.htm");
         file_put_contents(KISS_Framework_Config::getSystemPath('template') . "/{$this->mTemplateFile}", $output);
     }
 }