Add sorting to fetchAll

This commit is contained in:
2024-01-09 23:35:11 -03:00
parent 72a2ffe924
commit 74b3bb42ea

View File

@ -45,11 +45,14 @@ abstract class Repository implements Define\Repository
->where("{$this->getKey()} = ?");
return $this->fetchOne($query, [$id]);
}
public function fetchAll(): array
public function fetchAll(null|string|array $ordering = null): array
{
$query = $this->connection->getQueryBuilder()
->select()
->from($this->getTable());
if ($ordering !== null) {
$query->order($ordering);
}
return $this->fetchMany($query);
}