mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-06 23:02:48 +08:00
改进一对一关联预载入查询 支持使用IN方式 一对一关联类增加setEagerlyType方法用于设置预载入查询方式 默认为JOIN方式,setEagerlyType(1) 使用IN方式
Loader类的parseName方法增加第三个参数 用于驼峰法转换是否首字母大写
This commit is contained in:
@@ -27,8 +27,7 @@ use think\exception\PDOException;
|
||||
use think\Loader;
|
||||
use think\Model;
|
||||
use think\model\Relation;
|
||||
use think\model\relation\BelongsTo;
|
||||
use think\model\relation\HasOne;
|
||||
use think\model\relation\OneToOne;
|
||||
use think\Paginator;
|
||||
|
||||
class Query
|
||||
@@ -1653,9 +1652,9 @@ class Query
|
||||
}
|
||||
|
||||
/** @var Relation $model */
|
||||
$relation = Loader::parseName($relation, 1);
|
||||
$relation = Loader::parseName($relation, 1, false);
|
||||
$model = $class->$relation();
|
||||
if ($model instanceof HasOne || $model instanceof BelongsTo) {
|
||||
if ($model instanceof OneToOne && 0 == $model->getEagerlyType()) {
|
||||
$model->eagerly($this, $relation, $subRelation, $closure, $first);
|
||||
$first = false;
|
||||
} elseif ($closure) {
|
||||
|
||||
Reference in New Issue
Block a user