Пример #1
0
 /**
  *
  * 动态方法实现
  *
  * @access public
  *
  * @param string $method 方法名称
  * @param array $args 调用参数
  *
  * @return mixed
  *
  */
 public function __call($method, $args)
 {
     if (strtolower(substr($method, 0, 8)) == 'relation') {
         $type = strtoupper(substr($method, 8));
         if (in_array($type, array('ADD', 'SAVE', 'DEL'), true)) {
             array_unshift($args, $type);
             return call_user_func_array(array(&$this, 'opRelation'), $args);
         }
     } else {
         return parent::__call($method, $args);
     }
 }
Пример #2
0
 /**
  * 实例化过滤条件对象实例
  */
 public static function criteria($attr = array(), $operator = '=', $logic = 'AND', $parent = null)
 {
     return Leb_Model::criteria($attr, $operator, $logic, $parent);
 }
Пример #3
0
 /**
  *
  * 对保存到数据库的数据进行处理
  *
  * @access protected
  *
  * @param mixed $data 要操作的数据
  *
  * @return boolean
  *
  */
 protected function _facade($data)
 {
     // 检查序列化字段
     $data = $this->_serializeField($data);
     return parent::_facade($data);
 }
Пример #4
0
 /**
  * 构造函数
  *
  * @param string $name 模型名称
  * @param array $dbConfig 数据库配置
  */
 public function __construct($name = __CLASS__, $dbConfig = '')
 {
     // 模型初始化
     $this->_initialize();
     // 获取模型名称
     $this->_name = $name;
     //使用默认配置
     if (empty($dbConfig)) {
         $dbConfig = (require _CONFIG_ . 'db.php');
     }
     $this->_dao = Leb_Dao_Abstract::getInstance($dbConfig);
     if (isset($dbConfig['debug'])) {
         self::$debug = $dbConfig['debug'];
         $this->_dao->setDaoType($this->_daoType);
         $this->_dao->debug = $dbConfig['debug'];
     }
     //表单令牌验证
     defined('_TOKEN_ON_') && (self::$tokenOn = _TOKEN_ON_);
     defined('_TOKEN_NAME_') && (self::$tokenName = _TOKEN_NAME_);
     isset($dbConfig['dbFieldtypeCheck']) && (self::$dbFieldtypeCheck = $dbConfig['dbFieldtypeCheck']);
     // 设置表前缀
     $modelName = get_class($this);
     $refc = new ReflectionClass($modelName);
     $tpprop = $refc->getProperty('_tablePrefix');
     $decl = $tpprop->getDeclaringClass();
     if ($tpprop->class != $modelName) {
         $this->_tablePrefix = $this->_tablePrefix ? $this->_tablePrefix : @$dbConfig['tablePrefix'];
         $this->_tableSuffix = $this->_tableSuffix ? $this->_tableSuffix : @$dbConfig['tableSuffix'];
     }
     //初始化数据库名
     if ('' == $this->_dbName) {
         if (isset($dbConfig[self::DB_CFG_MASTER][self::DB_CFG_DBNAME])) {
             $this->_dbName = $dbConfig[self::DB_CFG_MASTER][self::DB_CFG_DBNAME];
         } else {
             isset($dbConfig[self::DB_CFG_DBNAME]) && ($this->_dbName = $dbConfig[self::DB_CFG_DBNAME]);
         }
     }
     $this->_dbConfig = $dbConfig;
     unset($dbConfig);
     // lazyed check table
     if (!empty($this->_tableName) && $this->_autoCheckFields) {
         // $this->_checkTableInfo();
     }
 }