字段填充方式string更改为value 修正mysql驱动一处BUG

This commit is contained in:
thinkphp
2016-02-10 20:50:51 +08:00
parent ebde8513dc
commit b47c455da6
2 changed files with 16 additions and 11 deletions

View File

@@ -971,7 +971,8 @@ class Model
protected function _create_filter(&$data) protected function _create_filter(&$data)
{} {}
protected function dataValidate(&$data){ protected function dataValidate(&$data)
{
if (!empty($this->options['validate'])) { if (!empty($this->options['validate'])) {
if (is_string($this->options['validate'])) { if (is_string($this->options['validate'])) {
// 读取配置文件中的自动验证定义 // 读取配置文件中的自动验证定义
@@ -1030,7 +1031,8 @@ class Model
return; return;
} }
protected function dataFill(&$data){ protected function dataFill(&$data)
{
if (!empty($this->options['auto'])) { if (!empty($this->options['auto'])) {
if (is_string($this->options['auto'])) { if (is_string($this->options['auto'])) {
// 读取配置文件中的自动验证定义 // 读取配置文件中的自动验证定义
@@ -1065,7 +1067,7 @@ class Model
$data[$key] = App::invokeFunction($val, [$value, $data]); $data[$key] = App::invokeFunction($val, [$value, $data]);
} else { } else {
$rule = isset($val[0]) ? $val[0] : $val; $rule = isset($val[0]) ? $val[0] : $val;
$type = isset($val[1]) ? $val[1] : 'string'; $type = isset($val[1]) ? $val[1] : 'value';
switch ($type) { switch ($type) {
case 'behavior': case 'behavior':
Hook::exec($rule, '', $data); Hook::exec($rule, '', $data);
@@ -1078,7 +1080,7 @@ class Model
unset($data[$key]); unset($data[$key]);
} }
break; break;
case 'string': case 'value':
default: default:
$data[$key] = $rule; $data[$key] = $rule;
break; break;

View File

@@ -50,6 +50,9 @@ class Mysql extends Driver
{ {
$this->initConnect(true); $this->initConnect(true);
list($tableName) = explode(' ', $tableName); list($tableName) = explode(' ', $tableName);
if (strpos($tableName, '.')) {
$tableName = str_replace('.', '`.`', $tableName);
}
$sql = 'SHOW COLUMNS FROM `' . $tableName . '`'; $sql = 'SHOW COLUMNS FROM `' . $tableName . '`';
$result = $this->query($sql); $result = $this->query($sql);
$info = []; $info = [];