|
|
|
@ -79,9 +79,9 @@ class Model {
|
|
|
|
|
'table' => $j['table'] ?? $j[0],
|
|
|
|
|
'from' => $j['from'] ?? $j[1],
|
|
|
|
|
'to' => $j['to'] ?? $j[2],
|
|
|
|
|
'sym' => $j['sym'] ?? ($j[3] ?? '='),
|
|
|
|
|
'symb' => $j['symb'] ?? ($j[3] ?? '='),
|
|
|
|
|
'alias' => $j['alias'] ?? '',
|
|
|
|
|
'type' => strtolower($j['type']) ?? '',
|
|
|
|
|
'type' => strtolower($j['type'] ?? ''),
|
|
|
|
|
'params' => $j['params'] ?? ''
|
|
|
|
|
];
|
|
|
|
|
$this->joins []= $join;
|
|
|
|
@ -97,8 +97,8 @@ class Model {
|
|
|
|
|
$cond = (object) [
|
|
|
|
|
'column' => $c['column'] ?? $c[0],
|
|
|
|
|
'value' => $c['value'] ?? $c[1],
|
|
|
|
|
'sym' => strtolower($c['sym'] ?? ($c[2] ?? '=')),
|
|
|
|
|
'type' => strtolower($c['type']) ?? ''
|
|
|
|
|
'symb' => strtolower($c['symb'] ?? ($c[2] ?? '=')),
|
|
|
|
|
'type' => strtolower($c['type'] ?? '')
|
|
|
|
|
];
|
|
|
|
|
$this->conditions []= $cond;
|
|
|
|
|
}
|
|
|
|
@ -154,7 +154,7 @@ class Model {
|
|
|
|
|
return $orm;
|
|
|
|
|
}
|
|
|
|
|
foreach ($this->columns as $col) {
|
|
|
|
|
$orm = $orm->select(trim(implode('.', $col), '.'));
|
|
|
|
|
$orm = $orm->select(trim(implode('.', (array) $col), '.'));
|
|
|
|
|
}
|
|
|
|
|
return $orm;
|
|
|
|
|
}
|
|
|
|
@ -192,7 +192,7 @@ class Model {
|
|
|
|
|
}
|
|
|
|
|
if ($join->type == 'raw') {
|
|
|
|
|
$orm = $orm->{$method}($join->table, [$join->from, $join->symb, $join->to], $join->alias, $join->params);
|
|
|
|
|
} elseif ($join->alias === '') {
|
|
|
|
|
} elseif ($join->alias !== '') {
|
|
|
|
|
$orm = $orm->{$method}($join->table, [$join->from, $join->symb, $join->to], $join->alias);
|
|
|
|
|
} else {
|
|
|
|
|
$orm = $orm->{$method}($join->table, [$join->from, $join->symb, $join->to]);
|
|
|
|
@ -206,7 +206,7 @@ class Model {
|
|
|
|
|
}
|
|
|
|
|
foreach ($this->conditions as $cond) {
|
|
|
|
|
$method = 'where';
|
|
|
|
|
switch ($cond->sym) {
|
|
|
|
|
switch ($cond->symb) {
|
|
|
|
|
case '<':
|
|
|
|
|
$method = 'whereLt';
|
|
|
|
|
break;
|
|
|
|
@ -363,10 +363,13 @@ class Model {
|
|
|
|
|
return $results;
|
|
|
|
|
}
|
|
|
|
|
public function array(): ?array {
|
|
|
|
|
$results = $this->build()->findArray();
|
|
|
|
|
if (!$results) {
|
|
|
|
|
$results = $this->many();
|
|
|
|
|
if (!$results or $results === null) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
array_walk($results, function(&$item) {
|
|
|
|
|
$item = $item->toArray();
|
|
|
|
|
});
|
|
|
|
|
return $results;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|