Skip to content

Commit cf20a9f

Browse files
committed
改进Model类废弃字段判断
1 parent 84d9b78 commit cf20a9f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Model.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function __construct($data = [])
114114
if ($this->disuse) {
115115
// 废弃字段
116116
foreach ((array) $this->disuse as $key) {
117-
if (isset($this->data[$key])) {
117+
if (array_key_exists($key, $this->data)) {
118118
unset($this->data[$key]);
119119
}
120120
}
@@ -184,7 +184,8 @@ public function newInstance($data = [], $isUpdate = false, $where = null)
184184
protected function buildQuery()
185185
{
186186
// 设置当前模型 确保查询返回模型对象
187-
$query = Db::connect($this->connection)->model($this);
187+
$class = $this->query;
188+
$query = (new $class())->connect($this->connection)->model($this);
188189

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

0 commit comments

Comments
 (0)