umutau
(Umutau)
November 1, 2011, 8:25am
1
Hi,
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);
jayant
(Codesutras)
November 1, 2011, 9:09am
2
umutau:
Hi,
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.
mdomba
(Maurizio Domba Cerin)
November 1, 2011, 9:12am
3
NOTE: moved to proper section "General discussion" instead of #Design Discussion for Yii 2.0"
umutau
(Umutau)
November 12, 2011, 10:50am
4
I tried to use
$state=State::model()->findAll('country=:country',array(':country'=>'xxx'), array('order'=>'name'));
but didn’t work
andy_s
(Arekandrei)
November 12, 2011, 11:06am
5
Try this:
$state=State::model()->findAll(array(
'condition'=>'country=:country',
'order'=>'name',
'params'=>array(
':country'=>'xxx',
),
));
I doubt you can do it more easily