Skip to content

Commit

Permalink
改进批量数组查询
Browse files Browse the repository at this point in the history
  • Loading branch information
liu21st committed Mar 6, 2023
1 parent ce9f1d2 commit 2e1a1a5
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/db/concern/WhereQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -494,18 +494,15 @@ protected function whereEq(string $field, $value): array
*/
protected function parseArrayWhereItems(array $field, string $logic)
{
if (key($field) !== 0) {
$where = [];
foreach ($field as $key => $val) {
if ($val instanceof Raw) {
$where[] = [$key, 'exp', $val];
} else {
$where[] = is_null($val) ? [$key, 'NULL', ''] : [$key, is_array($val) ? 'IN' : '=', $val];
}
$where = [];
foreach ($field as $key => $val) {
if (is_int($key)) {
$where[] = $val;
} elseif ($val instanceof Raw) {
$where[] = [$key, 'exp', $val];
} else {
$where[] = is_null($val) ? [$key, 'NULL', ''] : [$key, is_array($val) ? 'IN' : '=', $val];
}
} else {
// 数组批量查询
$where = $field;
}

if (!empty($where)) {
Expand Down

0 comments on commit 2e1a1a5

Please sign in to comment.