mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 15:12:48 +08:00
修正Model类一处BUG
This commit is contained in:
@@ -234,7 +234,7 @@ class Model
|
|||||||
unset($data[$key]);
|
unset($data[$key]);
|
||||||
} elseif (is_scalar($val) && !isset($this->options['bind'][$key])) {
|
} elseif (is_scalar($val) && !isset($this->options['bind'][$key])) {
|
||||||
// 字段类型检查
|
// 字段类型检查
|
||||||
$this->_parseType($data, $key, $this->options['bind']);
|
$this->_parseType($this->getTableName(), $data, $key, $this->options['bind']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -808,7 +808,7 @@ class Model
|
|||||||
$key = trim($key);
|
$key = trim($key);
|
||||||
if (in_array($key, $fields, true)) {
|
if (in_array($key, $fields, true)) {
|
||||||
if (is_scalar($val) && empty($options['bind'][$key])) {
|
if (is_scalar($val) && empty($options['bind'][$key])) {
|
||||||
$this->_parseType($options['where'], $key, $options['bind']);
|
$this->_parseType($options['table'], $options['where'], $key, $options['bind']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -826,14 +826,15 @@ class Model
|
|||||||
/**
|
/**
|
||||||
* 数据类型检测
|
* 数据类型检测
|
||||||
* @access protected
|
* @access protected
|
||||||
|
* @param string $table 表名
|
||||||
* @param array $data 数据
|
* @param array $data 数据
|
||||||
* @param string $key 字段名
|
* @param string $key 字段名
|
||||||
* @param array $bind 参数绑定列表
|
* @param array $bind 参数绑定列表
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function _parseType(&$data, $key, &$bind)
|
protected function _parseType($table, &$data, $key, &$bind)
|
||||||
{
|
{
|
||||||
$binds = $this->getTableInfo('', 'bind');
|
$binds = $this->getTableInfo($table, 'bind');
|
||||||
$bind[$key] = [$data[$key], isset($binds[$key]) ? $binds[$key] : \PDO::PARAM_STR];
|
$bind[$key] = [$data[$key], isset($binds[$key]) ? $binds[$key] : \PDO::PARAM_STR];
|
||||||
$data[$key] = ':' . $key;
|
$data[$key] = ':' . $key;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1114,7 +1114,7 @@ abstract class Driver
|
|||||||
*/
|
*/
|
||||||
public function getLastSql($model = '')
|
public function getLastSql($model = '')
|
||||||
{
|
{
|
||||||
return $model ? $this->modelSql[$model] : $this->queryStr;
|
return ($model && isset($this->modelSql[$model])) ? $this->modelSql[$model] : $this->queryStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user