改进where方法的原生sql条件 并且支持参数绑定

This commit is contained in:
thinkphp
2016-04-28 14:19:55 +08:00
parent 43fb7cc445
commit 810a88a48e
2 changed files with 8 additions and 2 deletions

View File

@@ -491,7 +491,13 @@ class Query
if (is_string($field) && !empty($this->options['via'])) {
$field = $this->options['via'] . '.' . $field;
}
if (is_null($op) && is_null($condition)) {
if (is_string($field) && strpos($field, ' ')) {
$where[] = ['exp', $field];
if (is_array($op)) {
// 参数绑定
$this->bind($op);
}
} elseif (is_null($op) && is_null($condition)) {
if (is_array($field)) {
// 数组批量查询
$where = $field;