Yii Criteria
1822 ワード
Yii Criteriaの一般的な方法(select,join,where,日付,)
参照先:
http://hi.baidu.com/bxbyg/item/b360f73194e5c8302e0f81c5
http://stackoverflow.com/questions/4983864/yii-cdbcriteria-join
$criteria = new CDbCriteria;
//select
$criteria->select = '*';// *
$criteria->select = 'id,name';//
$criteria->select = 't.*,t.id,t.name';// , as t, t.*
$criteria->distinct = FALSE; //
//join
$criteria->join = 'left join table2 t2 on(t.id=t2.tid)'; //
$criteria->with = 'xxx'; // relations
//where
$criteria->addCondition("id=1"); // , where id = 1
$criteria->addBetweenCondition('id', 1, 4);//between 1 and 4
$criteria->addInCondition('id', array(1,2,3,4,5)); // where id IN (1,23,,4,5,);
$criteria->addNotInCondition('id', array(1,2,3,4,5));// , NOT IN
//where
$criteria->addSearchCondition('name', ' ');// , 。。where name like '% %'
//where
$criteria->addCondition("create_time>'2012-11-29 00:00:00'");
$criteria->addCondition("create_timeaddCondition('id=1','OR');// OR , , OR AND
// , addCondition addInCondition,
// addInCondition
$criteria->compare('id', 1);
/** * */
$criteria->addCondition("id = :id");
$criteria->params[':id']=1;
//order
$criteria->order = 'xxx DESC,XXX ASC' ;//
//group
$criteria->group = 'group ';
$criteria->having = 'having ';
//limit
$criteria->limit = 10; // 1 , 0,
$criteria->offset = 1; // , limit 10 offset 1, 。limit 1,10
参照先:
http://hi.baidu.com/bxbyg/item/b360f73194e5c8302e0f81c5
http://stackoverflow.com/questions/4983864/yii-cdbcriteria-join