From ebde0fc13e7d5179e28fa4d518b2aa3fb550afe7 Mon Sep 17 00:00:00 2001 From: molong Date: Sun, 7 Aug 2016 07:44:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=86=85=E6=A0=B8=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common/controller/Base.php | 1 + core/convention.php | 2 ++ core/library/think/App.php | 16 ++++++--- core/library/think/Model.php | 3 +- core/library/think/db/Connection.php | 42 +++++++++++------------- core/library/think/view/driver/Think.php | 4 +-- 6 files changed, 36 insertions(+), 32 deletions(-) diff --git a/application/common/controller/Base.php b/application/common/controller/Base.php index 4ebca11b..9196ffde 100644 --- a/application/common/controller/Base.php +++ b/application/common/controller/Base.php @@ -144,6 +144,7 @@ class Base extends \think\Controller{ defined('IS_POST') or define('IS_POST', $this->request->isPost()); defined('IS_GET') or define('IS_GET', $this->request->isGet()); $this->url = $this->request->module() . '/' . $this->request->controller() . '/' . $this->request->action(); + $this->assign('request',$this->request); $this->assign('param',$this->param); } diff --git a/core/convention.php b/core/convention.php index d9003ca6..faf7571b 100644 --- a/core/convention.php +++ b/core/convention.php @@ -81,6 +81,8 @@ return [ 'url_param_type' => 0, // 是否开启路由 'url_route_on' => true, + // 路由配置文件(支持配置多个) + 'route_config_file' => ['route'], // 是否强制使用路由 'url_route_must' => false, // 域名部署 diff --git a/core/library/think/App.php b/core/library/think/App.php index 1d272ac3..c52c0ff7 100644 --- a/core/library/think/App.php +++ b/core/library/think/App.php @@ -483,13 +483,19 @@ class App if (is_array($rules)) { Route::rules($rules); } - } elseif (is_file(CONF_PATH . 'route' . CONF_EXT)) { - // 导入路由配置 - $rules = include CONF_PATH . 'route' . CONF_EXT; - if (is_array($rules)) { - Route::import($rules); + } else { + $files = $config['route_config_file']; + foreach ($files as $file) { + if (is_file(CONF_PATH . $file . CONF_EXT)) { + // 导入路由配置 + $rules = include CONF_PATH . $file . CONF_EXT; + if (is_array($rules)) { + Route::import($rules); + } + } } } + // 路由检测(根据路由定义返回不同的URL调度) $result = Route::check($request, $path, $depr, $config['url_domain_deploy']); $must = !is_null(self::$routeMust) ? self::$routeMust : $config['url_route_must']; diff --git a/core/library/think/Model.php b/core/library/think/Model.php index a870f347..a6c7341c 100644 --- a/core/library/think/Model.php +++ b/core/library/think/Model.php @@ -783,10 +783,9 @@ abstract class Model implements \JsonSerializable, \ArrayAccess /** * 删除当前的记录 * @access public - * @param bool $force 是否强制删除 * @return integer */ - public function delete($force = false) + public function delete() { if (false === $this->trigger('before_delete', $this)) { return false; diff --git a/core/library/think/db/Connection.php b/core/library/think/db/Connection.php index c4e09e6d..6712e0d9 100644 --- a/core/library/think/db/Connection.php +++ b/core/library/think/db/Connection.php @@ -68,47 +68,45 @@ abstract class Connection // 数据库连接参数配置 protected $config = [ // 数据库类型 - 'type' => '', + 'type' => '', // 服务器地址 - 'hostname' => '', + 'hostname' => '', // 数据库名 - 'database' => '', + 'database' => '', // 用户名 - 'username' => '', + 'username' => '', // 密码 - 'password' => '', + 'password' => '', // 端口 - 'hostport' => '', + 'hostport' => '', // 连接dsn - 'dsn' => '', + 'dsn' => '', // 数据库连接参数 - 'params' => [], + 'params' => [], // 数据库编码默认采用utf8 - 'charset' => 'utf8', + 'charset' => 'utf8', // 数据库表前缀 - 'prefix' => '', + 'prefix' => '', // 数据库调试模式 - 'debug' => false, + 'debug' => false, // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) - 'deploy' => 0, + 'deploy' => 0, // 数据库读写是否分离 主从式有效 - 'rw_separate' => false, + 'rw_separate' => false, // 读写分离后 主服务器数量 - 'master_num' => 1, + 'master_num' => 1, // 指定从服务器序号 - 'slave_no' => '', + 'slave_no' => '', // 是否严格检查字段是否存在 - 'fields_strict' => true, + 'fields_strict' => true, // 数据集返回类型 - 'resultset_type' => 'array', + 'resultset_type' => 'array', // 自动写入时间戳字段 - 'auto_timestamp' => false, + 'auto_timestamp' => false, // 是否需要进行SQL性能分析 - 'sql_explain' => false, + 'sql_explain' => false, // Builder类 - 'builder' => '', - // 软删除字段 - 'soft_delete_field' => '', + 'builder' => '', ]; // PDO连接参数 diff --git a/core/library/think/view/driver/Think.php b/core/library/think/view/driver/Think.php index f550e915..1521eca3 100644 --- a/core/library/think/view/driver/Think.php +++ b/core/library/think/view/driver/Think.php @@ -39,9 +39,7 @@ class Think if (empty($this->config['view_path'])) { $this->config['view_path'] = App::$modulePath . 'view' . DS; } - if (App::$debug) { - $this->config['tpl_cache'] = false; - } + $this->template = new Template($this->config); }