更新tp内核

This commit is contained in:
2016-09-20 22:58:29 +08:00
parent 8e3a918182
commit 3edc0909c0
4 changed files with 31 additions and 8 deletions

View File

@@ -104,6 +104,8 @@ abstract class Connection
'sql_explain' => false,
// Builder类
'builder' => '',
// Query类
'query' => '\\think\\db\\Query',
];
// PDO连接参数
@@ -131,12 +133,14 @@ abstract class Connection
* 创建指定模型的查询对象
* @access public
* @param string $model 模型类名称
* @param string $queryClass 查询对象类名
* @return Query
*/
public function model($model)
public function model($model, $queryClass = '')
{
if (!isset($this->query[$model])) {
$this->query[$model] = new Query($this, $model);
$class = $queryClass ?: $this->config['query'];
$this->query[$model] = new $class($this, $model);
}
return $this->query[$model];
}
@@ -151,7 +155,8 @@ abstract class Connection
public function __call($method, $args)
{
if (!isset($this->query['database'])) {
$this->query['database'] = new Query($this);
$class = $this->config['query'];
$this->query['database'] = new $class($this);
}
return call_user_func_array([$this->query['database'], $method], $args);
}