FIX: where

This commit is contained in:
2020-03-10 19:01:52 -03:00
parent 92745c62a8
commit 92ea9e4c7f

View File

@ -52,7 +52,8 @@ class Model {
if (is_string($column)) { if (is_string($column)) {
$column = [$column]; $column = [$column];
} }
$alias = $column['alias'] ?? $column[1] ?? $column[0]; $value = $column[0];
$alias = $column['alias'] ?? $column[1] ?? '';
$method = 'select'; $method = 'select';
if (count($column) > 2 or isset($column['type'])) { if (count($column) > 2 or isset($column['type'])) {
$type = $column['type'] ?? $column[2] ?? ''; $type = $column['type'] ?? $column[2] ?? '';
@ -62,7 +63,11 @@ class Model {
break; break;
} }
} }
$orm = $orm->{$method}($column, $alias); if ($alias == '') {
$orm = $orm->{$method}($value);
continue;
}
$orm = $orm->{$method}($value, $alias);
} }
return $orm; return $orm;
} }
@ -138,14 +143,17 @@ class Model {
if (isset($condition['operator'])) { if (isset($condition['operator'])) {
$op = strtolower($condition['operator']); $op = strtolower($condition['operator']);
} }
$mod = ['=' => '', '>' => 'Gt', '>=' => 'Gte', '<' => 'Lt', '<=', 'Lte']; $mod = ['=' => '', '>' => 'Gt', '>=' => 'Gte', '<' => 'Lt', '<=' => 'Lte', '!=' => 'NotEqual'];
if (isset($mod[$op])) { if (isset($mod[$op])) {
$method .= $mod[$op]; $method .= $mod[$op];
} else { } else {
switch ($op) { switch (strtolower($op)) {
case 'raw': case 'raw':
$method = 'rawWhere'; $method = 'rawWhere';
break; break;
case 'like':
$method = 'whereLike';
break;
} }
} }
$column = $condition[0]; $column = $condition[0];