FIX: array_walk returns bool and tertiary operator
This commit is contained in:
@ -133,9 +133,10 @@ abstract class Model extends BaseModel implements ModelInterface {
|
|||||||
$obj = static::find($factory, $input);
|
$obj = static::find($factory, $input);
|
||||||
} else {
|
} else {
|
||||||
$where = $data;
|
$where = $data;
|
||||||
$where = array_values(array_walk($where, function(&$item, $key) {
|
array_walk($where, function(&$item, $key) {
|
||||||
$item = [$key, $item];
|
$item = [$key, $item];
|
||||||
}));
|
});
|
||||||
|
$where = array_values($where);
|
||||||
$obj = $factory->find($class)->where($where)->one();
|
$obj = $factory->find($class)->where($where)->one();
|
||||||
}
|
}
|
||||||
if ($obj === null) {
|
if ($obj === null) {
|
||||||
|
@ -81,7 +81,7 @@ class Model {
|
|||||||
'to' => $j['to'] ?? $j[2],
|
'to' => $j['to'] ?? $j[2],
|
||||||
'sym' => $j['sym'] ?? ($j[3] ?? '='),
|
'sym' => $j['sym'] ?? ($j[3] ?? '='),
|
||||||
'alias' => $j['alias'] ?? '',
|
'alias' => $j['alias'] ?? '',
|
||||||
'type' => strtolower($j['type']) ?? '',
|
'type' => strtolower($j['type'] ?? ''),
|
||||||
'params' => $j['params'] ?? ''
|
'params' => $j['params'] ?? ''
|
||||||
];
|
];
|
||||||
$this->joins []= $join;
|
$this->joins []= $join;
|
||||||
@ -98,7 +98,7 @@ class Model {
|
|||||||
'column' => $c['column'] ?? $c[0],
|
'column' => $c['column'] ?? $c[0],
|
||||||
'value' => $c['value'] ?? $c[1],
|
'value' => $c['value'] ?? $c[1],
|
||||||
'sym' => strtolower($c['sym'] ?? ($c[2] ?? '=')),
|
'sym' => strtolower($c['sym'] ?? ($c[2] ?? '=')),
|
||||||
'type' => strtolower($c['type']) ?? ''
|
'type' => strtolower($c['type'] ?? '')
|
||||||
];
|
];
|
||||||
$this->conditions []= $cond;
|
$this->conditions []= $cond;
|
||||||
}
|
}
|
||||||
@ -363,10 +363,13 @@ class Model {
|
|||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
public function array(): ?array {
|
public function array(): ?array {
|
||||||
$results = $this->build()->findArray();
|
$results = $this->many();
|
||||||
if (!$results) {
|
if (!$results or $results === null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
array_walk($results, function(&$item) {
|
||||||
|
$item = $item->toArray();
|
||||||
|
});
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user