예제 #1
0
 public function __construct($tableName = '')
 {
     //如果没有设置表名,则自动根据Model名取表名
     if (null != $tableName && "" == $this->table) {
         $this->table = $tableName;
     }
     //如果没有设置数据库配置文件,读取默认文件
     if (null == $this->_dbConfig) {
         $this->_dbConfig = registry::getRegistry('db');
     }
     parent::__construct($this->_dbConfig);
 }
예제 #2
0
 /**
  * 初始化
  * 设置变量,初始化参数,调用公用方法
  * @param object $actionName 方法名
  * @param object $db 数据库链接
  */
 public function __construct($actionName)
 {
     $viewCacheKey = $_SERVER['REQUEST_URI'];
     $viewCache = zcache::get($viewCacheKey);
     if ($viewCache) {
         echo $viewCache;
         exit;
     }
     //取全局配置变量
     $global_configs = registry::getRegistry('global');
     //如果有配置tpl_set变量,取tpl_set变量
     if (isset($global_configs["tpl_set"])) {
         $this->tpl_set = $global_configs["tpl_set"];
     }
     //如果有配置lang_set变量,取lang_set变量
     if (isset($global_configs["lang_set"])) {
         $this->lang_set = $global_configs["lang_set"];
     }
     //多模板样式检测
     $this->checkTplSet();
     //多语言检测
     $this->checkLangSet();
     //包含语言文件
     $langfile = "./lang/" . $this->lang_set . "/lang.php";
     if (file_exists($langfile)) {
         $this->lang = (include_once $langfile);
     }
     //包含系统语言文件
     $syslangfile = zvc_path . "/lang/" . $this->lang_set . "/sys.php";
     if (file_exists($syslangfile)) {
         $this->syslang = (include_once $syslangfile);
     }
     //设置uri请求变量
     $this->req_uri = $_SERVER['REQUEST_URI'];
     //获取精确的类名
     $className = get_class($this);
     //获取文件的目录
     $fileDir = str_replace('Action', '', $className);
     //前缀目录
     $fullFileDir = "./views/" . $this->tpl_set . "/" . $fileDir . "/";
     //完整的文件名
     $fullFileName = $fullFileDir . $actionName . ".html";
     //设置模版文件名
     $this->tplFileName = $fullFileName;
     //get_magic_quote_gpc();
     $this->magicQuote = get_magic_quotes_gpc();
     //如果有_init公用方法,则进行调用
     if (method_exists($this, "_init")) {
         $this->_init();
     }
 }
예제 #3
0
 /**
  * 获取数据库对象
  * @param object $dbConfig
  * @return
  */
 public static function db($dbConfig = null)
 {
     if (!isset(self::$db)) {
         if (!$dbConfig) {
             self::$db = new db(registry::getRegistry('db'));
         } else {
             self::$db = new db($dbConfig);
         }
     }
     return self::$db;
 }
 /**
  * 获取全局变量里面存储的Soap变量
  * @return array 
  */
 public static function getSoapConfig()
 {
     return registry::getRegistry('soap');
 }
예제 #5
0
 /**
  * 构建真实表名
  * @param object $table
  * @return 
  */
 public function tableName($table)
 {
     $dbConfig = registry::getRegistry('db');
     $db_prefix = $dbConfig['db_prefix'];
     return $db_prefix . $table;
 }
예제 #6
0
 /**
  * Tracer错误信息
  * @param object $e
  * @return
  */
 public static function traceOut(Exception $e)
 {
     if (!file_exists('./config/global.php')) {
         self::throwTrace($e);
     } else {
         $global_setting = registry::getRegistry('global');
         switch ($global_setting['run_mode']) {
             case 'product':
                 self::message($e->getMessage(), null, 'disableRedirect');
                 break;
             case 'dev':
                 self::throwTrace($e);
                 break;
         }
     }
 }