改进多对多关联

This commit is contained in:
thinkphp
2018-10-26 16:12:11 +08:00
parent 26380b7019
commit f89cc5a6e4
8 changed files with 101 additions and 9 deletions

View File

@@ -188,15 +188,19 @@ class MorphMany extends Relation
}
/**
* 获取关联统计子查询
* 创建关联统计子查询
* @access public
* @param \Closure $closure 闭包
* @param string $name 统计数据别名
* @return string
*/
public function getRelationCountQuery($closure)
public function getRelationCountQuery($closure, &$name = null)
{
if ($closure) {
call_user_func_array($closure, [ & $this->query]);
$return = call_user_func_array($closure, [ & $this->query]);
if ($return && is_string($return)) {
$name = $return;
}
}
return $this->query->where([