mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 20:52:48 +08:00
关联预载入查询支持关联统计
This commit is contained in:
@@ -1620,10 +1620,11 @@ class Query
|
||||
/**
|
||||
* 设置关联查询JOIN预查询
|
||||
* @access public
|
||||
* @param string|array $with 关联方法名称
|
||||
* @param string|array $with 关联方法名称
|
||||
* @param bool $count 是否统计
|
||||
* @return $this
|
||||
*/
|
||||
public function with($with)
|
||||
public function with($with, $count = false)
|
||||
{
|
||||
if (empty($with)) {
|
||||
return $this;
|
||||
@@ -1662,7 +1663,8 @@ class Query
|
||||
}
|
||||
}
|
||||
$this->via();
|
||||
$this->options['with'] = $with;
|
||||
$this->options['with'] = $with;
|
||||
$this->options['count'] = $count;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -2017,7 +2019,7 @@ class Query
|
||||
}
|
||||
if (!empty($options['with'])) {
|
||||
// 预载入
|
||||
$result->eagerlyResultSet($resultSet, $options['with'], is_object($resultSet) ? get_class($resultSet) : '');
|
||||
$result->eagerlyResultSet($resultSet, $options['with'], is_object($resultSet) ? get_class($resultSet) : '', !empty($options['count']) ? true : false);
|
||||
}
|
||||
}
|
||||
// 模型数据集转换
|
||||
@@ -2113,7 +2115,7 @@ class Query
|
||||
}
|
||||
// 预载入查询
|
||||
if (!empty($options['with'])) {
|
||||
$data->eagerlyResult($data, $options['with'], is_object($result) ? get_class($result) : '');
|
||||
$data->eagerlyResult($data, $options['with'], is_object($result) ? get_class($result) : '', !empty($options['count']) ? true : false);
|
||||
}
|
||||
// 关联统计
|
||||
if (!empty($options['with_count'])) {
|
||||
|
||||
Reference in New Issue
Block a user