From ba7232b678b2beea40950983a07c9600aa02b483 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sun, 15 Jan 2017 18:50:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0laodRelation=E5=8A=A9?= =?UTF-8?q?=E6=89=8B=E5=87=BD=E6=95=B0=20=E7=94=A8=E4=BA=8E=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=9B=86=E7=9A=84=E5=BB=B6=E8=BF=9F=E9=A2=84=E8=BD=BD?= =?UTF-8?q?=E5=85=A5=E5=85=B3=E8=81=94=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helper.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/helper.php b/helper.php index 83dbddda..f26400c3 100644 --- a/helper.php +++ b/helper.php @@ -548,3 +548,20 @@ if (!function_exists('token')) { return ''; } } + +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; + } +}