有没有办法用ORDER BY FIELD()功能创建CDbCriteria实例?
列是glncrna_id,id_list:'GlncRNA10003d','GlncRNA10027d','GlncRNA20024d'
$criteria1->order = "FIELD(glncrna_id, 'GlncRNA10003d', 'GlncRNA10027d', 'GlncRNA20024d')";
或
$criteria1->order = "FIELD('glncrna_id', GlncRNA10003d, GlncRNA10027d, GlncRNA20024d)";
或
$criteria1->order = "FIELD('glncrna_id', 'GlncRNA10003d, GlncRNA10027d, GlncRNA20024d')";
显示一般错误:1没有这样的功能:FIELD
$criteria1->order = "FIELD(glncrna_id, GlncRNA10003d, GlncRNA10027d, GlncRNA20024d)";
显示不是GlncRNA10003d柱
如何在id_list中订购结果?我使用sqlite数据库
答案 0 :(得分:1)
试试这个:
$criteria1=new CDbCriteria; <br/>
$criteria1->order="FIELD(glncrna_id,'GlncRNA10003d','GlncRNA10027d','GlncRNA20024d') DESC";
答案 1 :(得分:0)
您必须使用Cshort按
使用不同的顺序 $sort = new CSort();
//this should be default order
$sort->defaultOrder = 't.glncrna_id DESC';
$sort->attributes = array(
'GlncRNA10003d' => array(
'asc' => 'GlncRNA10003d asc',
'desc' => 'GlncRNA10003d desc'
),
'GlncRNA10027d' => array(
'asc' => 'GlncRNA10003d asc',
'desc' => 'GlncRNA10027d desc'
),
);
$dataProvider = new CActiveDataProvider('ModelName', array(
'criteria' => $criteria,
'sort' => $sort
));