method treatConditions documentation in bbn\Db\Languages\Sql

function(array $where, bool $full = true) { if (!isset($where['conditions'])) { $where['conditions'] = $where; } if (isset($where['conditions']) && \is_array($where['conditions'])) { if (!isset($where['logic']) || (strtoupper($where['logic']) !== 'OR')) { $where['logic'] = 'AND'; } $res = [ 'conditions' => [], 'logic' => $where['logic'] ]; foreach ($where['conditions'] as $key => $f){ $is_array = \is_array($f); if ($is_array && array_key_exists('conditions', $f) && \is_array($f['conditions']) ) { $res['conditions'][] = $this->treatConditions($f, false); } else { if (\is_string($key)) { // 'id_user' => [1, 2] Will do OR if (!$is_array) { if (null === $f) { $f = [ 'field' => $key, 'operator' => 'isnull' ]; } else{ $f = [ 'field' => $key, 'operator' => is_string($f) && !Str::isUid($f) ? 'LIKE' : '=', 'value' => $f ]; } } elseif (isset($f[0])) { $tmp = [ 'conditions' => [], 'logic' => 'OR' ]; foreach ($f as $v){ if (null === $v) { $tmp['conditions'][] = [ 'field' => $key, 'operator' => 'isnull' ]; } else{ $tmp['conditions'][] = [ 'field' => $key, 'operator' => is_string($f) && !Str::isUid($f) ? 'LIKE' : '=', 'value' => $v ]; } } $res['conditions'][] = $tmp; } } elseif ($is_array && !X::isAssoc($f) && count($f) >= 2) { $tmp = [ 'field' => $f[0], 'operator' => $f[1] ]; if (isset($f[3])) { $tmp['exp'] = $f[3]; } elseif (array_key_exists(2, $f)) { if (is_array($f[2])) { $tmp = [ 'conditions' => [], 'logic' => 'AND' ]; foreach ($f[2] as $v){ if (null === $v) { $tmp['conditions'][] = [ 'field' => $f[0], 'operator' => 'isnotnull' ]; } else{ $tmp['conditions'][] = [ 'field' => $f[0], 'operator' => $f[1], 'value' => $v ]; } } $res['conditions'][] = $tmp; } elseif ($f[2] === null) { $tmp['operator'] = $f[2] === '!=' ? 'isnotnull' : 'isnull'; } else{ $tmp['value'] = $f[2]; } } $f = $tmp; } if (isset($f['field'])) { if (!isset($f['operator'])) { $f['operator'] = 'eq'; } $res['conditions'][] = $f; } } } if ($full) { $tmp = $this->_remove_conditions_value($res); $res = [ 'hashed' => $tmp['hashed'], 'values' => $tmp['values'], 'where' => $res ]; } return $res; } return false; }

BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way

This website uses cookies to ensure you get the best experience on our website.