Revert "关联预载入查询支持关联统计"

This reverts commit 9657ee01b1.
This commit is contained in:
thinkphp
2016-12-22 13:30:43 +08:00
parent 9657ee01b1
commit bde2607442
5 changed files with 16 additions and 52 deletions

View File

@@ -13,7 +13,6 @@ namespace think\model\relation;
use think\Db;
use think\db\Query;
use think\Loader;
use think\Model;
use think\model\Pivot;
use think\model\Relation;
@@ -81,10 +80,9 @@ class BelongsToMany extends Relation
* @param string $subRelation 子关联名
* @param \Closure $closure 闭包
* @param string $class 数据集对象名 为空表示数组
* @param bool $count 是否统计
* @return void
*/
public function eagerlyResultSet(&$resultSet, $relation, $subRelation, $closure, $class, $count)
public function eagerlyResultSet(&$resultSet, $relation, $subRelation, $closure, $class)
{
$localKey = $this->localKey;
$foreignKey = $this->foreignKey;
@@ -112,10 +110,7 @@ class BelongsToMany extends Relation
if (!isset($data[$result->$pk])) {
$data[$result->$pk] = [];
}
if ($count) {
// 关联统计
$result->setAttr(Loader::parseName($relation) . '_count', count($data[$result->$pk]));
}
$result->setAttr($relation, $this->resultSetBuild($data[$result->$pk], $class));
}
}
@@ -129,10 +124,9 @@ class BelongsToMany extends Relation
* @param string $subRelation 子关联名
* @param \Closure $closure 闭包
* @param string $class 数据集对象名 为空表示数组
* @param bool $count 是否统计
* @return void
*/
public function eagerlyResult(&$result, $relation, $subRelation, $closure, $class, $count)
public function eagerlyResult(&$result, $relation, $subRelation, $closure, $class)
{
$localKey = $this->localKey;
$foreignKey = $this->foreignKey;
@@ -147,10 +141,6 @@ class BelongsToMany extends Relation
if (!isset($data[$pk])) {
$data[$pk] = [];
}
if ($count) {
// 关联统计
$result->setAttr(Loader::parseName($relation) . '_count', count($data[$pk]));
}
$result->setAttr($relation, $this->resultSetBuild($data[$pk], $class));
}
}