内核更新

This commit is contained in:
2016-12-28 10:41:09 +08:00
parent c89254e12a
commit ffab826db0
65 changed files with 1194 additions and 610 deletions

View File

@@ -16,7 +16,6 @@ use PDOStatement;
use think\Collection;
use think\Db;
use think\db\exception\BindParamException;
use think\db\Query;
use think\Debug;
use think\Exception;
use think\exception\PDOException;
@@ -65,47 +64,49 @@ 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,
// 时间字段取出后的默认时间格式
'datetime_format' => 'Y-m-d H:i:s',
// 是否需要进行SQL性能分析
'sql_explain' => false,
'sql_explain' => false,
// Builder类
'builder' => '',
'builder' => '',
// Query类
'query' => '\\think\\db\\Query',
'query' => '\\think\\db\\Query',
];
// PDO连接参数
@@ -136,11 +137,11 @@ abstract class Connection
* @param string $queryClass 查询对象类名
* @return Query
*/
public function model($model, $queryClass = '')
public function getQuery($model = 'db', $queryClass = '')
{
if (!isset($this->query[$model])) {
$class = $queryClass ?: $this->config['query'];
$this->query[$model] = new $class($this, $model);
$this->query[$model] = new $class($this, 'db' == $model ? '' : $model);
}
return $this->query[$model];
}
@@ -154,11 +155,7 @@ abstract class Connection
*/
public function __call($method, $args)
{
if (!isset($this->query['database'])) {
$class = $this->config['query'];
$this->query['database'] = new $class($this);
}
return call_user_func_array([$this->query['database'], $method], $args);
return call_user_func_array([$this->getQuery(), $method], $args);
}
/**