From 298202984de70c5e8454d0069da325a8148975c4 Mon Sep 17 00:00:00 2001 From: huangdijia Date: Tue, 26 Jan 2016 13:17:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96think/cache/driver/Db.php?= =?UTF-8?q?=E9=A9=B1=E5=8A=A8=EF=BC=8C=E6=94=AF=E6=8C=81=E5=8D=95=E7=8B=AC?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=EF=BC=8C=E5=85=BC=E5=AE=B9=E9=BB=98=E8=AE=A4?= =?UTF-8?q?database=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/cache/driver/Db.php | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/library/think/cache/driver/Db.php b/library/think/cache/driver/Db.php index d428788b..7a350497 100644 --- a/library/think/cache/driver/Db.php +++ b/library/think/cache/driver/Db.php @@ -29,11 +29,18 @@ class Db protected $handler = null; protected $options = [ - 'db' => '', - 'table' => '', - 'prefix' => '', - 'expire' => 0, - 'length' => 0, + 'type' => '', + 'dsn' => '', + 'hostname' => '', + 'hostport' => '', + 'username' => '', + 'password' => '', + 'database' => '', + 'charset' => '', + 'table' => '', + 'prefix' => '', + 'expire' => 0, + 'length' => 0, ]; /** @@ -46,7 +53,7 @@ class Db if (!empty($options)) { $this->options = array_merge($this->options, $options); } - $this->handler = \Think\Db::connect(); + $this->handler = \think\Db::connect((!empty($this->options['hostname']) || !empty($this->options['dsn'])) ? $this->options : []); } /** @@ -155,4 +162,4 @@ class Db return $this->handler->execute('TRUNCATE TABLE `' . $this->options['table'] . '`'); } -} +} \ No newline at end of file