/**
* 分析查询表达式
* @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;
}// 根据 不同的情况 进行 不同的展示
转载于:https://blog.51cto.com/jingshanls/1881601