Add sorting to fetchAll
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user