php – Yii findAllByAttributes with BETWEEN DATES AND ORDER BY

前端之家收集整理的这篇文章主要介绍了php – Yii findAllByAttributes with BETWEEN DATES AND ORDER BY前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想在一个给定的日期范围内按属性进行搜索,并按创建日期排序,但没有运气.
$user = array('user_country'=>1,'user_gender'='M');
    $rows = User::model()->findAllByAttributes($user,array("user_date_created BETWEEN '2012' AND '2013' ",'order'=> 'user_date_created') );

先感谢您.

不得不使用 CDbCriteria,像这样:
$attribs = array('user_country'=>1,'user_gender'=>'M');
$criteria = new CDbCriteria(array('order'=>'user_date_created DESC','limit'=>10));
$criteria->addBetweenCondition('user_date_created',$date['date_start'],$date['date_end']);
$rows = user::model()->findAllByAttributes($attribs,$criteria);

希望它能帮助将来的某个人

猜你在找的PHP相关文章