优化catchQuery

This commit is contained in:
JaguarJack 2020-06-22 07:55:39 +08:00
parent a3dd8282b3
commit 6e76c173a7

View File

@ -24,7 +24,7 @@ class CatchQuery extends Query
$table = app($model)->getTable(); $table = app($model)->getTable();
// 合并字段 // 合并字段
$this->options['field'] = array_merge($this->options['field'], array_map(function ($value) use ($table) { $this->options['field'] = array_merge($this->options['field'] ?? [], array_map(function ($value) use ($table) {
return $table . '.' . $value; return $table . '.' . $value;
}, $field)); }, $field));
@ -222,7 +222,7 @@ class CatchQuery extends Query
*/ */
public function addSelectSub(callable $callable, string $as) public function addSelectSub(callable $callable, string $as)
{ {
$this->field(sprintf('%s as %s', $callable($this)->buildSql(), $as)); $this->field(sprintf('%s as %s', $callable()->buildSql(), $as));
return $this; return $this;
} }