改进查询条件的参数绑定

This commit is contained in:
thinkphp
2016-09-13 14:53:33 +08:00
parent f1c9a3bb88
commit e3a3acaed6

View File

@@ -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'])) {
// 比较运算 及 模糊匹配