mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
增加laodRelation助手函数 用于数据集的延迟预载入关联查询
This commit is contained in:
17
helper.php
17
helper.php
@@ -548,3 +548,20 @@ if (!function_exists('token')) {
|
||||
return '<input type="hidden" name="' . $name . '" value="' . $token . '" />';
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('loadRelation')) {
|
||||
/**
|
||||
* 延迟预载入关联查询
|
||||
* @param mixed $resultSet 数据集
|
||||
* @param mixed $relation 关联
|
||||
* @return array
|
||||
*/
|
||||
function loadRelation($resultSet, $relation)
|
||||
{
|
||||
$item = current($resultSet);
|
||||
if ($item instanceof Model) {
|
||||
$item->eagerlyResultSet($resultSet, $relation);
|
||||
}
|
||||
return $resultSet;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user