/**
* 分析查询表达式
* @access public
* @param mixed $data 主键列表或者查询条件(闭包)
* @param string $with 关联预查询
* @param bool $cache 是否缓存
* @return Query
*/
protected static function parseQuery(&$data, $with, $cache)//解析 sql 表达式
{
$result = self::with($with)->cache($cache);// 获取结果 关联查询 及 是否 进行缓存
// 根据 with 及 缓存 生成 对应的 句柄
if (is_array($data) && key($data) !== 0) {// 是数组 并且 数组的 key 不等于 0
$result = $result->where($data);// 获取 普通结果
$data = null;// 清空引入的条件
} elseif ($data instanceof \Closure) {// 如果是闭包 函数
call_user_func_array($data, [ & $result]);// 调用 数据
$data = null;// 清空引入 数据资源
} elseif ($data instanceof Query) {// 如果 是query 对象
$result = $data->with($with)->cache($cache);// 直接 自己进行执行
$data = null;
}
return $result;
}// 根据 不同的情况 进行 不同的展示
[李景山php]每天TP5-20170113|thinkphp5-Model.php-6
原创
©著作权归作者所有:来自51CTO博客作者lijingshan34的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章