Active Record Last Entries

Having a table with 10 rows, there should be a way to select last 5 rows but keeping them in ascending order.

Right now what you get by using "…order by id desc limit 5" is a (10,9,8,7,6), but their order should be (6,7,8,9,10)

It would be great if an option ‘limit -5’ could be added to data provider which would return last 5 records but in ascending order

It would really help if we can have limit -5 possibility. That could be arranged with CActiveDataProvider since it finds count for that query in most of time. Using that count, you could calculate offset for "limit -5"…

On the other way, if you are able to do it, you can always order them desc and limit to 5 and then use array_reverse from data that you get from data provider :). Of course that is not possible for built in things in framework and extensions…

if pagination is set to false, returned items are not calculated. and i don’t want to pass another query to do the count.

right now i do use array_reverse, which is a nice approach. but still, just adding a param to dataprovider would be even better. like you said, it could be applied everywhere :)