From b47c455da6e5899f2f663d1fcd766e8ee5906f83 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 10 Feb 2016 20:50:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=97=E6=AE=B5=E5=A1=AB=E5=85=85=E6=96=B9?= =?UTF-8?q?=E5=BC=8Fstring=E6=9B=B4=E6=94=B9=E4=B8=BAvalue=20=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3mysql=E9=A9=B1=E5=8A=A8=E4=B8=80=E5=A4=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Model.php | 18 ++++++++++-------- library/think/db/driver/Mysql.php | 9 ++++++--- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/library/think/Model.php b/library/think/Model.php index d426f236..8f89108f 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -291,7 +291,7 @@ class Model { // 数据处理 $data = $this->_write_data($data, 'insert'); - if(false === $data){ + if (false === $data) { return false; } // 分析表达式 @@ -333,7 +333,7 @@ class Model // 数据处理 foreach ($dataList as $key => $data) { $data = $this->_write_data($data, 'insert'); - if(false === $data){ + if (false === $data) { return false; } $dataList[$key] = $data; @@ -359,7 +359,7 @@ class Model { // 数据处理 $data = $this->_write_data($data, 'update'); - if(false === $data){ + if (false === $data) { return false; } // 分析表达式 @@ -971,7 +971,8 @@ class Model protected function _create_filter(&$data) {} - protected function dataValidate(&$data){ + protected function dataValidate(&$data) + { if (!empty($this->options['validate'])) { if (is_string($this->options['validate'])) { // 读取配置文件中的自动验证定义 @@ -1027,10 +1028,11 @@ class Model } $this->options['validate'] = null; } - return ; + return; } - protected function dataFill(&$data){ + protected function dataFill(&$data) + { if (!empty($this->options['auto'])) { if (is_string($this->options['auto'])) { // 读取配置文件中的自动验证定义 @@ -1065,7 +1067,7 @@ class Model $data[$key] = App::invokeFunction($val, [$value, $data]); } else { $rule = isset($val[0]) ? $val[0] : $val; - $type = isset($val[1]) ? $val[1] : 'string'; + $type = isset($val[1]) ? $val[1] : 'value'; switch ($type) { case 'behavior': Hook::exec($rule, '', $data); @@ -1078,7 +1080,7 @@ class Model unset($data[$key]); } break; - case 'string': + case 'value': default: $data[$key] = $rule; break; diff --git a/library/think/db/driver/Mysql.php b/library/think/db/driver/Mysql.php index a5720a7d..c08c6f59 100644 --- a/library/think/db/driver/Mysql.php +++ b/library/think/db/driver/Mysql.php @@ -50,9 +50,12 @@ class Mysql extends Driver { $this->initConnect(true); list($tableName) = explode(' ', $tableName); - $sql = 'SHOW COLUMNS FROM `' . $tableName . '`'; - $result = $this->query($sql); - $info = []; + if (strpos($tableName, '.')) { + $tableName = str_replace('.', '`.`', $tableName); + } + $sql = 'SHOW COLUMNS FROM `' . $tableName . '`'; + $result = $this->query($sql); + $info = []; if ($result) { foreach ($result as $key => $val) { $val = array_change_key_case($val);