public function all($db = null)
{
// TODO add support for orderBy
$data = $this->executeScript($db, 'All');
if (empty($data)) {
return [];
}
$rows = [];
foreach ($data as $dataRow) {
$row = [];
$c = count($dataRow);
for ($i = 0; $i < $c;) {
$row[$dataRow[$i++]] = $dataRow[$i++];
}
$rows[] = $row;
}
if (!empty($rows)) {
$models = $this->createModels($rows);
if (!empty($this->with)) {
$this->findWith($this->with, $models);
}
if (!$this->asArray) {
foreach ($models as $model) {
$model->afterFind();
}
}
return $models;
} else {
return [];
}
}