diff --git a/library/think/db/Builder.php b/library/think/db/Builder.php index 852b3a77..efd1c28b 100644 --- a/library/think/db/Builder.php +++ b/library/think/db/Builder.php @@ -296,10 +296,13 @@ abstract class Builder } } $bindType = isset($binds[$field]) ? $binds[$field] : PDO::PARAM_STR; - if (is_scalar($value) && array_key_exists($field, $binds) && !in_array($exp, ['IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN']) && strpos($exp, 'TIME') === false && strpos($value, ':') !== 0) { - $this->query->bind('where_' . $field, $value, $bindType); - $value = ':where_' . $field; + if (is_scalar($value) && array_key_exists($field, $binds) && !in_array($exp, ['IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN']) && strpos($exp, 'TIME') === false) { + if (strpos($value, ':') !== 0 || !$this->query->isBind(substr($value, 1))) { + $this->query->bind('where_' . $field, $value, $bindType); + $value = ':where_' . $field; + } } + $whereStr = ''; if (in_array($exp, ['=', '<>', '>', '>=', '<', '<=', 'LIKE', 'NOT LIKE'])) { // 比较运算 及 模糊匹配