diff --git a/library/think/model/relation/HasMany.php b/library/think/model/relation/HasMany.php index b132ea83..cf50a97a 100644 --- a/library/think/model/relation/HasMany.php +++ b/library/think/model/relation/HasMany.php @@ -245,7 +245,7 @@ class HasMany extends Relation return $this->parent->db() ->alias($model) ->field($model . '.*') - ->join($table . ' ' . $relation, $model . '.' . $this->localKey . '=' . $relation . '.' . $this->foreignKey, $joinType) + ->join([$table => $relation], $model . '.' . $this->localKey . '=' . $relation . '.' . $this->foreignKey, $joinType) ->group($relation . '.' . $this->foreignKey) ->having('count(' . $id . ')' . $operator . $count); } @@ -277,7 +277,7 @@ class HasMany extends Relation return $this->parent->db()->alias($model) ->field($fields) ->group($model . '.' . $this->localKey) - ->join($table . ' ' . $relation, $model . '.' . $this->localKey . '=' . $relation . '.' . $this->foreignKey) + ->join([$table => $relation], $model . '.' . $this->localKey . '=' . $relation . '.' . $this->foreignKey) ->where($where); }