I would like make order to database query. I can be able to this with CDBCriteria::order but is there any easy way, I dont want to create criteria every time when I try to get database query

I want something like

$state=State::model()->findAll('country=:country',array(':country'=>'xxx'), ORDER);

pass a argument array with a order attribute and define a value for it like "field_name ASC".

hope this will help you.

NOTE: moved to proper section "General discussion" instead of #Design Discussion for Yii 2.0"

I tried to use

$state=State::model()->findAll('country=:country',array(':country'=>'xxx'), array('order'=>'name'));

but didn’t work

Try this:








I doubt you can do it more easily :)

thanks it works