mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 20:52:48 +08:00
改进App类和Request类
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user