Skip to content

Commit

Permalink
改进Model类废弃字段判断
Browse files Browse the repository at this point in the history
  • Loading branch information
liu21st committed Dec 2, 2017
1 parent 84d9b78 commit cf20a9f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function __construct($data = [])
if ($this->disuse) {
// 废弃字段
foreach ((array) $this->disuse as $key) {
if (isset($this->data[$key])) {
if (array_key_exists($key, $this->data)) {
unset($this->data[$key]);
}
}
Expand Down Expand Up @@ -184,7 +184,8 @@ public function newInstance($data = [], $isUpdate = false, $where = null)
protected function buildQuery()
{
// 设置当前模型 确保查询返回模型对象
$query = Db::connect($this->connection)->model($this);
$class = $this->query;
$query = (new $class())->connect($this->connection)->model($this);

// 设置当前数据表和模型名
if (!empty($this->table)) {
Expand Down

0 comments on commit cf20a9f

Please sign in to comment.