按条件排序Yii不工作

时间:2016-10-05 11:28:15

标签: php yii

我正在尝试按特定顺序列出表中的值。但它是按条件工作的,而不是为其他条件工作。这是代码

$criteria = new CDbCriteria();
$criteria->condition = 'courseid =:courseid AND batchid =:batchid';
$criteria->params = array(':courseid' => $courseid, ':batchid' => $batchid); //Condition
$criteria->order = 'student_rollno ASC'; //Order by student roll no
$students = Student::model()->findAll($criteria);

1 个答案:

答案 0 :(得分:0)

您可以针对您的问题尝试此解决方案。

$criteria = new CDbCriteria();
$criteria->condition = 't.courseid =:course_id AND t.batchid =:batch_id';
$criteria->params = array(':course_id' => $courseid, ':batch_id' => $batchid); //Condition
$criteria->order = 't.student_rollno ASC'; //Order by student roll no
$students = Student::model()->findAll($criteria);