findAll() with sort

Hello, I am just trying to do a findAll with a sort. I just want to sort by the primary key (id) ASC, since for some reason it is not sorted in the database. Any help is appreciated, thanks.

Subsections::model()->findAll(array('criteria'=>array('order'='id')) //doesn't work, I can't find any examples of idea what the syntax is

Did you try:


thanks :)

can you tell me how to find the last value of findall().

please help me

There are several ways. If you’re using a findAll, you can just change the order and grab the first one.

‘order’=>‘id DESC’,