Yii Framework Forum: Cdbcriteria Order By Field(Xx,0), Xx Asc - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Cdbcriteria Order By Field(Xx,0), Xx Asc Rate Topic: -----

#1 User is offline   RTJ 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 42
  • Joined: 04-May 12

Posted 11 January 2013 - 05:01 AM

Hola,
Como puedo hacr algo parecido a esta consulta con CDbCriteria
SELECT * FROM YY ORDER BY FIELD(xx,0), xx asc;

0

#2 User is offline   sebas 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 498
  • Joined: 28-October 08
  • Location:Buenos Aires, Argentina

Posted 11 January 2013 - 07:21 AM

View PostRTJ, on 11 January 2013 - 05:01 AM, said:

Hola,
Como puedo hacr algo parecido a esta consulta con CDbCriteria
SELECT * FROM YY ORDER BY FIELD(xx,0), xx asc;





Hola,

Probá esto:

$models = MyModel::model()->findAll(array('order'=>'FIELD(idinvited_email,3,4,1,2)'));


o

$dbCriteria = new CDbCriteria();
$dbCriteria->order = 'FIELD('myfield', 3,4,1,2)';
$models = MyModel::model()->findAll($dbCriteria);


Saludos!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users