mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 15:12:48 +08:00
like查询条件支持数组
This commit is contained in:
@@ -334,9 +334,19 @@ abstract class Builder
|
|||||||
}
|
}
|
||||||
|
|
||||||
$whereStr = '';
|
$whereStr = '';
|
||||||
if (in_array($exp, ['=', '<>', '>', '>=', '<', '<=', 'LIKE', 'NOT LIKE'])) {
|
if (in_array($exp, ['=', '<>', '>', '>=', '<', '<='])) {
|
||||||
// 比较运算 及 模糊匹配
|
// 比较运算 及 模糊匹配
|
||||||
$whereStr .= $key . ' ' . $exp . ' ' . $this->parseValue($value, $field);
|
$whereStr .= $key . ' ' . $exp . ' ' . $this->parseValue($value, $field);
|
||||||
|
} elseif ('LIKE' == $exp || 'NOT LIKE' == $exp) {
|
||||||
|
if (is_array($value)) {
|
||||||
|
foreach ($value as $item) {
|
||||||
|
$array[] = $key . ' ' . $exp . ' ' . $this->parseValue($item, $field);
|
||||||
|
}
|
||||||
|
$logic = isset($val[2]) ? $val[2] : 'AND';
|
||||||
|
$whereStr .= '(' . implode($array, ' ' . strtoupper($logic) . ' ') . ')';
|
||||||
|
} else {
|
||||||
|
$whereStr .= $key . ' ' . $exp . ' ' . $this->parseValue($value, $field);
|
||||||
|
}
|
||||||
} elseif ('EXP' == $exp) {
|
} elseif ('EXP' == $exp) {
|
||||||
// 表达式查询
|
// 表达式查询
|
||||||
$whereStr .= '( ' . $key . ' ' . $value . ' )';
|
$whereStr .= '( ' . $key . ' ' . $value . ' )';
|
||||||
|
|||||||
@@ -1018,7 +1018,7 @@ class Query
|
|||||||
// 字段相等查询
|
// 字段相等查询
|
||||||
$where[$field] = ['eq', $op];
|
$where[$field] = ['eq', $op];
|
||||||
} else {
|
} else {
|
||||||
$where[$field] = [$op, $condition];
|
$where[$field] = [$op, $condition, isset($param[2]) ? $param[2] : null];
|
||||||
if ('exp' == strtolower($op) && isset($param[2]) && is_array($param[2])) {
|
if ('exp' == strtolower($op) && isset($param[2]) && is_array($param[2])) {
|
||||||
// 参数绑定
|
// 参数绑定
|
||||||
$this->bind($param[2]);
|
$this->bind($param[2]);
|
||||||
|
|||||||
Reference in New Issue
Block a user