This commit is contained in:
thinkphp
2017-09-07 11:40:07 +08:00
parent 6bab32b1ea
commit 56bce822f3

View File

@@ -244,6 +244,7 @@ class HasMany extends Relation
return $this->parent->db()
->alias($model)
->field($model . '.*')
->join($table . ' ' . $relation, $model . '.' . $this->localKey . '=' . $relation . '.' . $this->foreignKey, $joinType)
->group($relation . '.' . $this->foreignKey)
->having('count(' . $id . ')' . $operator . $count);