[李景山php]每天TP5-20170113|thinkphp5-Model.php-6

/**
 * 分析查询表达式
 * @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;
}// 根据 不同的情况 进行 不同的展示
时间: 2024-08-25 17:28:58

[李景山php]每天TP5-20170113|thinkphp5-Model.php-6的相关文章

[李景山php]每天laravel-20161010|Validator.php-10

   /**     * Validate the guessed extension of a file upload is in a set of file extensions.     *     * @param  string  $attribute     * @param  mixed  $value     * @param  array   $parameters     * @return bool     */    protected function validate

[李景山php]每天TP5-20161207|Loader.php-5

/**  * 实例化(分层)模型  * @param string $name         Model名称  * @param string $layer        业务层名称  * @param bool   $appendSuffix 是否添加类名后缀  * @param string $common       公共模块名  * @return Object  * @throws ClassNotFoundException  */ public static function m

[李景山php]每天TP5-20170115|thinkphp5-Model.php-8

    /**      * 预载入关联查询 返回模型对象      * @access public      * @param Model     $result 数据对象      * @param string    $relation 关联名      * @return Model      */     public function eagerlyResult($result, $relation)     {         return $this->relation()->

[李景山php]每天TP5-20170110|thinkphp5-Model.php-3

/**  * 自动写入时间戳  * @access public  * @param string         $name 时间戳字段  * @return mixed  */ protected function autoWriteTimestamp($name) {// 自动写入 时间戳     if (isset($this->type[$name])) {// 如果当期时间戳字段 拥有 类型         $type = $this->type[$name];// 获取当前字段 

[李景山php]每天TP5-20170108|thinkphp5-Model.php-1

<?php // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- // | Copyright (c) 2006~2016 http://thinkphp.cn All 

[李景山php]每天TP5-20161217|thinkphp5-helper.php-2

<?php // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- // | Copyright (c) 2006~2016 http://thinkphp.cn All 

[李景山php]每天TP5-20161224|thinkphp5-Console.php-1

namespace think; use think\console\Command;// 控制台 命令 use think\console\command\Help as HelpCommand; // 帮助命令 use think\console\Input;// 输入 use think\console\input\Argument as InputArgument;// 输入参数 use think\console\input\Definition as InputDefinition;

[李景山php]每天TP5-20161221|thinkphp5-jump.php

<?php /**  * 用法:  * load_trait('controller/Jump');  * class index  * {  *     use \traits\controller\Jump;  *     public function index(){  *         $this->error();  *         $this->redirect();  *     }  * }  */ namespace traits\controller; use

[李景山php]thinkphp核心源码注释|Driver.class.php

<?php // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK IT ] // +---------------------------------------------------------------------- // | Copyright (c) 2006-2014 http://thinkphp.cn A

[李景山php]thinkphp核心源码注释|Lite.class.php

<?php // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK IT ] // +---------------------------------------------------------------------- // | Copyright (c) 2006-2014 http://thinkphp.cn A