改进Query类和Build类 改进查询语法

This commit is contained in:
thinkphp
2016-04-28 14:06:06 +08:00
parent 006b45dd9a
commit 43fb7cc445
2 changed files with 31 additions and 31 deletions

View File

@@ -282,8 +282,15 @@ abstract class Builder
// 对一个字段使用多个查询条件
if (is_array($exp)) {
$item = array_pop($val);
// 传入 or 或者 and
if (is_string($item) && in_array($item, ['AND', 'and', 'OR', 'or'])) {
$rule = $item;
} else {
array_push($val, $item);
}
foreach ($val as $item) {
$str[] = $this->parseWhereItem($key, $item);
$str[] = $this->parseWhereItem($key, $item, $rule);
}
return '( ' . implode(' ' . $rule . ' ', $str) . ' )';
}