protected function parseWhereExp($logic, $field, $op, $condition, $param = [])
{
if ($field instanceof \Closure) {
$this->options['where'][$logic][] = is_string($op) ? [$op, $field] : $field;
return;
}
if (is_string($field) && !empty($this->options['via']) && !strpos($field, '.')) {
$field = $this->options['via'] . '.' . $field;
}
if (is_string($field) && preg_match('/[,=\\>\\<\'\\"\\(\\s]/', $field)) {
$where[] = ['exp', $field];
if (is_array($op)) {
// 参数绑定
$this->bind($op);
}
} elseif (is_null($op) && is_null($condition)) {
if (is_array($field)) {
// 数组批量查询
$where = $field;
} elseif ($field) {
// 字符串查询
if (is_numeric($field)) {
$where[] = ['exp', $field];
} else {
$where[$field] = ['null', ''];
}
}
} elseif (is_array($op)) {
$where[$field] = $param;
} elseif (in_array(strtolower($op), ['null', 'notnull', 'not null'])) {
// null查询
$where[$field] = [$op, ''];
} elseif (is_null($condition)) {
// 字段相等查询
$where[$field] = ['eq', $op];
} else {
$where[$field] = [$op, $condition];
}
if (!empty($where)) {
if (!isset($this->options['where'][$logic])) {
$this->options['where'][$logic] = [];
}
$this->options['where'][$logic] = array_merge($this->options['where'][$logic], $where);
}
}