forked from kvnZero/hyperf-APIJSON
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWhereRawHandle.php
More file actions
29 lines (27 loc) · 940 Bytes
/
WhereRawHandle.php
File metadata and controls
29 lines (27 loc) · 940 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
namespace App\ApiJson\Handle;
class WhereRawHandle extends AbstractHandle
{
protected function buildModel()
{
foreach (array_filter($this->condition->getCondition(), function($key){
return str_ends_with($key, '{}');
}, ARRAY_FILTER_USE_KEY) as $key => $value)
{
if (is_array($value)) continue;
$boolean = ' OR ';
$conditionArr = explode(',', (string)$value);
$sql = [];
foreach ($conditionArr as $condition) {
$sql[] = sprintf("`%s`%s", $this->sanitizeKey($key), trim($condition));
}
if (str_ends_with($key, '|{}')) {
$boolean = ' OR ';
} else if (str_ends_with($key, '&{}')) {
$boolean = ' AND ';
}
$this->condition->addQueryWhere($key, join($boolean, $sql), []);
$this->unsetKey[] = $key;
}
}
}