How do I make a SQL that fetches the newest rows, but reorder them, so that the newest is at the bottom of the output
6 5 4 3 2 1
1 2 3 4 5 6
How can i do this?
$resultSet = $this->modelsManager->createQuery(" SELECT * FROM (SELECT * FROM [Robots] ORDER BY id DESC LIMIT 10) tmp ORDER BY id ASC ")->execute();
Not sure if this will work with PHQL, but that is how you'd do it with mysql.
You could also convert your original ResultSet to array, and issue
array_reverse, but that's not a robust solution performance-wise
if I understand, you want to sort your resultset in the view environment. There is a "sort" filter implemented in volt, see: https://docs.phalconphp.com/en/latest/reference/volt.html#filters, but it will sort your items in an ASC order
I think, you will have to create your own filter to achieve what you exactly need, see https://docs.phalconphp.com/en/latest/reference/volt.html#id2