内核更新
This commit is contained in:
@@ -12,9 +12,6 @@
|
||||
namespace think\db;
|
||||
|
||||
use PDO;
|
||||
use think\Db;
|
||||
use think\db\Connection;
|
||||
use think\db\Query;
|
||||
use think\Exception;
|
||||
|
||||
abstract class Builder
|
||||
@@ -118,6 +115,9 @@ abstract class Builder
|
||||
$this->query->bind($key, $val, isset($bind[$key]) ? $bind[$key] : PDO::PARAM_STR);
|
||||
$result[$item] = ':' . $key;
|
||||
}
|
||||
} elseif (is_object($val) && method_exists($val, '__toString')) {
|
||||
// 对象数据写入
|
||||
$result[$item] = $val->__toString();
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
@@ -317,6 +317,11 @@ abstract class Builder
|
||||
}
|
||||
}
|
||||
$bindName = $bindName ?: 'where_' . str_replace('.', '_', $field);
|
||||
if (preg_match('/\W/', $bindName)) {
|
||||
// 处理带非单词字符的字段名
|
||||
$bindName = md5($bindName);
|
||||
}
|
||||
|
||||
$bindType = isset($binds[$field]) ? $binds[$field] : PDO::PARAM_STR;
|
||||
if (is_scalar($value) && array_key_exists($field, $binds) && !in_array($exp, ['EXP', 'NOT NULL', 'NULL', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN']) && strpos($exp, 'TIME') === false) {
|
||||
if (strpos($value, ':') !== 0 || !$this->query->isBind(substr($value, 1))) {
|
||||
@@ -702,8 +707,13 @@ abstract class Builder
|
||||
throw new Exception('fields not exists:[' . $key . ']');
|
||||
}
|
||||
unset($data[$key]);
|
||||
} elseif (is_null($val)) {
|
||||
$data[$key] = 'NULL';
|
||||
} elseif (is_scalar($val)) {
|
||||
$data[$key] = $this->parseValue($val, $key);
|
||||
} elseif (is_object($val) && method_exists($val, '__toString')) {
|
||||
// 对象数据写入
|
||||
$data[$key] = $val->__toString();
|
||||
} else {
|
||||
// 过滤掉非标量数据
|
||||
unset($data[$key]);
|
||||
|
||||
Reference in New Issue
Block a user