Answer the question
In order to leave comments, you need to log in
Why doesn't $criteria->order work in Yii?
Such a trouble, you need to sort the list by field in the table ` ORDER `
$criteria = new CDbCriteria();
1) I tried this: - swears at the word ORDER (system), I put it in `quotes`
2) I try - the records still go through the field CODE(AI , PRIMARY KEY)
3) - the same as 2)
When I tried the item 1) received such a thing
Added quotes and inserted into phpmyadmin naked:
In this case, I got the records in the order I needed. But I don't understand where the `t` came from and why the records are displayed.
But the most important thing is how to make this criterion work? $criteria->order = 'ORDER ASC';
$criteria->order = '`ORDER` ASC'
$criteria->order = '`ORDER`'
SELECT * FROM `mc_slider` `t` ORDER BY ORDER
SELECT * FROM `mc_slider` `t` ORDER BY `ORDER`
Answer the question
In order to leave comments, you need to log in
`t` is an alias for the table, ActiveRecord adds it.
What request was generated in the second case?
But the most important thing is how to make this criterion work?
$criteria->order = '`t`.`sortFeild` ASC';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question