From f63706eb0ac03ad51b9fc5fb5e884857719bc4a4 Mon Sep 17 00:00:00 2001 From: wuyanwen Date: Mon, 13 Jan 2020 21:40:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9EaddFields=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/catcher/CatchQuery.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/extend/catcher/CatchQuery.php b/extend/catcher/CatchQuery.php index 9ae49ee..79a0ebf 100644 --- a/extend/catcher/CatchQuery.php +++ b/extend/catcher/CatchQuery.php @@ -87,12 +87,14 @@ class CatchQuery extends Query $field = array_merge((array) $this->options['field'], $field); } + $this->options['field'] = array_unique($field); + if ($needAlias) { $alias = $this->getAlias(); $this->options['field'] = array_map(function ($field) use ($alias) { return $alias . '.' . $field; - }, array_unique($field)); + }, $this->options['field']); } return $this; @@ -145,4 +147,18 @@ class CatchQuery extends Query return parent::whereLike($this->getAlias() . '.' . $field, $condition, $logic); } + + /** + * 额外的字段 + * + * @time 2020年01月13日 + * @param array $fields + * @return CatchQuery + */ + public function addFields(array $fields): CatchQuery + { + $this->options['field'] = array_merge($this->options['field'], $fields); + + return $this; + } }