twtech
(Tedwebtech)
1
Hello to all!
Is there any way to create CDbCriteria instance with ORDER BY FIELD() feature? My straightforward approach does not work:
$criteria = new CDbCriteria;
$criteria->condition = "id IN ($idSlice)";
$criteria->order = "FIELD (id, $idSlice)";
Got an error:
twtech
(Tedwebtech)
2
Doh! All I needed to do is to remove the space between FIELD
and the bracket:
$criteria->order = "FIELD(id, $idSlice)";
Lame! 
ibiz4
(Ibiz4)
3
is that any "elegant" way to pass list id to FIELD() function in YII ??
i expect passing the id list in array format $criteria->order = ‘field’=>array(‘id’,array(13,15,14)); or similar like that.
instead of using this nasty way $criteria->order = “FIELD(id, ‘13,15,14’)”;
xiaosizhe
(Xiaosizheme)
4
I also have this error
Column is glncrna_id, id_list: ‘GlncRNA10003d’, ‘GlncRNA10027d’, ‘GlncRNA20024d’
$criteria1->order = "FIELD(glncrna_id, 'GlncRNA10003d', 'GlncRNA10027d', 'GlncRNA20024d')";
and
$criteria1->order = "FIELD('glncrna_id', GlncRNA10003d, GlncRNA10027d, GlncRNA20024d)";
shows General error: 1 no such function: FIELD
$criteria1->order = "FIELD(glncrna_id, GlncRNA10003d, GlncRNA10027d, GlncRNA20024d)";
shows not GlncRNA10003d column
How to order result in the id_list ?