mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 15:12:48 +08:00
改进Query类的parseExpress方法
This commit is contained in:
@@ -1836,23 +1836,20 @@ class Query
|
|||||||
if (!isset($options['where'])) {
|
if (!isset($options['where'])) {
|
||||||
$options['where'] = [];
|
$options['where'] = [];
|
||||||
} elseif (isset($options['view'])) {
|
} elseif (isset($options['view'])) {
|
||||||
if (isset($options['where']['AND'])) {
|
// 视图查询条件处理
|
||||||
foreach ($options['where']['AND'] as $key => $val) {
|
foreach (['AND', 'OR'] as $logic) {
|
||||||
if (array_key_exists($key, $options['map'])) {
|
if (isset($options['where'][$logic])) {
|
||||||
$options['where']['AND'][$options['map'][$key]] = $val;
|
foreach ($options['where'][$logic] as $key => $val) {
|
||||||
unset($options['where']['AND'][$key]);
|
if (array_key_exists($key, $options['map'])) {
|
||||||
}
|
$options['where'][$logic][$options['map'][$key]] = $val;
|
||||||
}
|
unset($options['where'][$logic][$key]);
|
||||||
}
|
}
|
||||||
if (isset($options['where']['OR'])) {
|
|
||||||
foreach ($options['where']['OR'] as $key => $val) {
|
|
||||||
if (array_key_exists($key, $options['map'])) {
|
|
||||||
$options['where']['OR'][$options['map'][$key]] = $val;
|
|
||||||
unset($options['where']['OR'][$key]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($options['order'])) {
|
if (isset($options['order'])) {
|
||||||
|
// 视图查询排序处理
|
||||||
if (is_string($options['order'])) {
|
if (is_string($options['order'])) {
|
||||||
$options['order'] = explode(',', $options['order']);
|
$options['order'] = explode(',', $options['order']);
|
||||||
}
|
}
|
||||||
@@ -1864,17 +1861,13 @@ class Query
|
|||||||
$options['order'][$options['map'][$field]] = $sort;
|
$options['order'][$options['map'][$field]] = $sort;
|
||||||
unset($options['order'][$key]);
|
unset($options['order'][$key]);
|
||||||
}
|
}
|
||||||
} else {
|
} elseif (array_key_exists($val, $options['map'])) {
|
||||||
if (array_key_exists($val, $options['map'])) {
|
$options['order'][$options['map'][$val]] = 'asc';
|
||||||
$options['order'][$options['map'][$val]] = 'asc';
|
|
||||||
unset($options['order'][$key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (array_key_exists($key, $options['map'])) {
|
|
||||||
$options['order'][$options['map'][$key]] = $val;
|
|
||||||
unset($options['order'][$key]);
|
unset($options['order'][$key]);
|
||||||
}
|
}
|
||||||
|
} elseif (array_key_exists($key, $options['map'])) {
|
||||||
|
$options['order'][$options['map'][$key]] = $val;
|
||||||
|
unset($options['order'][$key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user