Browse Source

update field

朱金辉 3 tháng trước cách đây
mục cha
commit
462b6e319d
1 tập tin đã thay đổi với 8 bổ sung4 xóa
  1. 8 4
      src/Driver/Entity/Base.php

+ 8 - 4
src/Driver/Entity/Base.php

@@ -978,8 +978,11 @@ class Base {
      *
      * @return \Qii\Driver\Base
      */
-    public function createQuery() {
-        $query = $this->db()->fields($this->getFields())->where($this->getWhereHooker())->fetchSql($this->calledSQL);
+    public function createQuery($fields = []) {
+        if(empty($fields)) {
+            $fields = $this->getFields();
+        }
+        $query = $this->db()->fields($fields)->where($this->getWhereHooker())->fetchSql($this->calledSQL);
         $or = $this->getOrHooker();
         foreach ($or as $v) {
             $query = $query->orTerms($v);
@@ -1172,7 +1175,8 @@ class Base {
         if(count($this->getFields()) > 0 && !in_array($relKey, $this->getFields())) {
             $fields[] = $relKey;
         }
-        $query = $this->createQuery()->fields($fields, true);
+        $fields = array_unique($fields);
+        $query = $this->createQuery($fields);
         $res = $query->where($args[1])->rs($this->prepareTable());
         $rows = [];
         foreach($res as $v) {
@@ -1200,7 +1204,7 @@ class Base {
         if(count($this->getFields()) > 0 && !in_array($relKey, $this->getFields())) {
             $fields[] = $relKey;
         }
-        $query = $this->createQuery()->fields($fields, true);
+        $query = $this->createQuery($fields);
         $res = $query->where($args[1])->rs($this->prepareTable());
         echo $this->calledSQL;
         $rows = [];