From 7f13d70d0b4eb5cb813fe1b38dd637119ede262d Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 24 Jun 2016 23:41:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BApp=E7=B1=BB=E5=92=8CRequest?= =?UTF-8?q?=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/App.php | 25 ++++++++++++++++++++----- library/think/Request.php | 8 +++----- library/think/db/builder/Sqlsrv.php | 11 ++++++----- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/library/think/App.php b/library/think/App.php index 8a46c4fb..2ebf6d52 100644 --- a/library/think/App.php +++ b/library/think/App.php @@ -64,6 +64,8 @@ class App */ protected static $routeMust; + protected static $dispatch; + /** * 执行应用程序 * @access public @@ -90,12 +92,14 @@ class App } } - // 获取当前请求的调度信息 - $dispatch = $request->dispatch(); + // 获取应用调度信息 + $dispatch = self::$dispatch; if (empty($dispatch)) { // 未指定调度类型 则进行URL路由检测 $dispatch = self::routeCheck($request, $config); } + // 记录当前调度信息 + $request->dispatch($dispatch); // 记录路由信息 self::$debug && Log::record('[ ROUTE ] ' . var_export($dispatch, true), 'info'); // 监听app_begin @@ -150,6 +154,19 @@ class App } } + /** + * 设置当前请求的调度信息 + * @access public + * @param array|string $dispatch 调度信息 + * @param string $type 调度类型 + * @param array $params 参数 + * @return void + */ + public static function dispatch($dispath, $type = 'module', $params = []) + { + self::$dispatch = ['type' => $type, $type => $dispatch, 'params' => $params]; + } + /** * 执行函数或者闭包方法 支持参数调用 * @access public @@ -453,9 +470,7 @@ class App // 路由无效 解析模块/控制器/操作/参数... 支持控制器自动搜索 $result = Route::parseUrl($path, $depr, $config['controller_auto_search'], $config['url_param_type']); } - - // 注册调度机制 - return $request->dispatch($result); + return $result; } /** diff --git a/library/think/Request.php b/library/think/Request.php index 493f7ad9..8d5e9ad4 100644 --- a/library/think/Request.php +++ b/library/think/Request.php @@ -1296,15 +1296,13 @@ class Request /** * 设置或者获取当前请求的调度信息 * @access public - * @param array|string $dispatch 调度信息 - * @param string $type 调度类型 - * @param array $params 参数 + * @param array $dispatch 调度信息 * @return array */ - public function dispatch($dispatch = null, $type = 'module', $params = []) + public function dispatch($dispatch = null) { if (!is_null($dispatch)) { - $this->dispatch = ['type' => $type, $type => $dispatch, 'params' => $params]; + $this->dispatch = $dispatch; } return $this->dispatch; } diff --git a/library/think/db/builder/Sqlsrv.php b/library/think/db/builder/Sqlsrv.php index 4010fe3c..8cc0f324 100644 --- a/library/think/db/builder/Sqlsrv.php +++ b/library/think/db/builder/Sqlsrv.php @@ -18,10 +18,10 @@ use think\db\Builder; */ class Sqlsrv extends Builder { - protected $selectSql = 'SELECT T1.* FROM (SELECT thinkphp.*, ROW_NUMBER() OVER (%ORDER%) AS ROW_NUMBER FROM (SELECT %DISTINCT% %FIELD% FROM %TABLE%%JOIN%%WHERE%%GROUP%%HAVING%) AS thinkphp) AS T1 %LIMIT%%COMMENT%'; + protected $selectSql = 'SELECT T1.* FROM (SELECT thinkphp.*, ROW_NUMBER() OVER (%ORDER%) AS ROW_NUMBER FROM (SELECT %DISTINCT% %FIELD% FROM %TABLE%%JOIN%%WHERE%%GROUP%%HAVING%) AS thinkphp) AS T1 %LIMIT%%COMMENT%'; protected $selectInsertSql = 'SELECT %DISTINCT% %FIELD% FROM %TABLE%%JOIN%%WHERE%%GROUP%%HAVING%'; - protected $updateSql = 'UPDATE %TABLE% SET %SET% %JOIN% %WHERE% %LIMIT% %LOCK%%COMMENT%'; - protected $deleteSql = 'DELETE FROM %TABLE% %USING% %JOIN% %WHERE% %LIMIT% %LOCK%%COMMENT%'; + protected $updateSql = 'UPDATE %TABLE% SET %SET% %JOIN% %WHERE% %LIMIT% %LOCK%%COMMENT%'; + protected $deleteSql = 'DELETE FROM %TABLE% %USING% %JOIN% %WHERE% %LIMIT% %LOCK%%COMMENT%'; /** * order分析 @@ -79,9 +79,10 @@ class Sqlsrv extends Builder } return 'WHERE ' . $limitStr; } - public function selectInsert($fields, $table, $options) + + public function selectInsert($fields, $table, $options) { - $this->selectSql=$this->selectInsertSql; + $this->selectSql = $this->selectInsertSql; return parent::selectInsert($fields, $table, $options); }