Exemple #1
0
 /**
  * Constructor
  *
  * @param  array $settings
  */
 public function __construct($settings = [])
 {
     $this->settings = array_merge($this->settings, $settings);
     $this->messages = ['prev' => [], 'next' => [], 'now' => []];
     // 加载会话消息
     $this->loadMessages();
     parent::__construct();
 }
Exemple #2
0
 /**
  * ORM的构造方法,可以传参来直接加载模型数据
  *
  * @param  mixed $id 查询参数
  */
 public function __construct($id = null)
 {
     parent::__construct();
     if (null !== $id) {
         if (is_array($id)) {
             foreach ($id as $column => $value) {
                 $this->where($column, '=', $value);
             }
             $this->find();
         } else {
             $this->where($this->_objectName . '.' . $this->_primaryKey, '=', $id)->find();
         }
     } elseif (!empty($this->_castData)) {
         // Load preloaded data from a database call cast
         $this->_loadValues($this->_castData);
         $this->_castData = [];
     }
 }