简体   繁体   中英

How to obtain only 3 results specified by 3 ID's from a MySQL table using the powerful Yii Framework and it's CActiveRecord/CDbCriteria compontents?

I'm wondering how can I find these records using the CActiveRecord / CDbCriteria in Yii:

[table]         
 id | value     
 ---------------
  1 | horses    
  2 | snakes    
  3 | panteras  
  4 | commandos 

As I said, I want only the three first witch I will specify in the right order: 1, 2 and 3.

How is this possible to achieve in Yii?

yourmodel()::model()->findAll(array( 'criteria' => id <= 4) );

if the ids will be non consecutive, use addInCondition to the cdbcriteria object.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM