/**
     * 动态切换扩展模型
     * @access public
     * @param string $type 模型类型名称
     * @param mixed $vars 要传入扩展模型的属性变量
     * @return Model
     */
    public function switchModel($type,$vars=array()) {
        $class = ucwords(strtolower($type)).'Model';
        if(!class_exists($class))
            throw_exception($class.L('_MODEL_NOT_EXIST_'));
        // 实例化扩展模型
        $this->_extModel   = new $class($this->name);
        if(!empty($vars)) {
            // 传入当前模型的属性到扩展模型
            foreach ($vars as $var)
                $this->_extModel->setProperty($var,$this->$var);
        }
        return $this->_extModel;
    }

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-19
  • 2022-12-23
  • 2022-12-23
  • 2021-05-07
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-19
  • 2021-11-28
  • 2021-06-03
  • 2021-06-22
相关资源
相似解决方案