Answer the question
In order to leave comments, you need to log in
Yii 1.x: Why doesn't sorting work in CActiveRecord?
I'm trying to get data from the model by sorting it by the sort_order field. The code is like this:
// Данные меню
$menu = Menu::model()->findAll('', array('order'=>'sort_order') );
foreach($menu as $item)
echo $item['text'];
Answer the question
In order to leave comments, you need to log in
As far as I remember, it should be like this:
$menu = Menu::model()->findAll(array('order'=>'sort_order'));
Try it through CDBcriteria, it will be easier to understand the code later:
$criteria = new CDbCriteria;
$criteria->order = 'sort_order DESC';
$model = findAll($criteria);
three days ago the question arose how to bind to AR orderby. Driven into Google https://www.google.com/search?q=yii+findall+orderb...
on the first link the correct example. What's stopping you from doing so? it will take about 15 seconds.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question