From 6e721239ea23f991f65140a4961fe559c8d1aa61 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Thu, 11 May 2017 18:39:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E7=B1=BB=E7=9A=84=E4=B8=80=E5=A4=84=E4=B8=8D=E8=83=BD=E5=B5=8C?= =?UTF-8?q?=E5=A5=97=E6=9F=A5=E8=AF=A2=E7=9A=84=E7=BC=BA=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Model.php | 1 - library/think/db/Connection.php | 30 +++++------------------------- 2 files changed, 5 insertions(+), 26 deletions(-) diff --git a/library/think/Model.php b/library/think/Model.php index 535d76a2..88897f48 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -176,7 +176,6 @@ abstract class Model implements \JsonSerializable, \ArrayAccess // 设置当前模型 确保查询返回模型对象 $queryClass = $this->query ?: $con->getConfig('query'); $query = new $queryClass($con, $this->class); - $con->setQuery($query, $this->class); // 设置当前数据表和模型名 if (!empty($this->table)) { diff --git a/library/think/db/Connection.php b/library/think/db/Connection.php index 908384cb..7dd54abd 100644 --- a/library/think/db/Connection.php +++ b/library/think/db/Connection.php @@ -56,8 +56,6 @@ abstract class Connection protected $attrCase = PDO::CASE_LOWER; // 监听回调 protected static $event = []; - // 查询对象 - protected $query = []; // 使用Builder类 protected $builder; // 数据库连接参数配置 @@ -137,32 +135,14 @@ abstract class Connection } /** - * 指定当前使用的查询对象 - * @access public - * @param Query $query 查询对象 - * @return $this - */ - public function setQuery($query, $model = 'db') - { - $this->query[$model] = $query; - - return $this; - } - - /** - * 创建指定模型的查询对象 - * @access public + * 获取新的查询对象 + * @access protected * @return Query */ - public function getQuery($model = 'db') + protected function getQuery() { - if (!isset($this->query[$model])) { - $class = $this->config['query']; - - $this->query[$model] = new $class($this, 'db' == $model ? '' : $model); - } - - return $this->query[$model]; + $class = $this->config['query']; + return new $class($this); } /**