简体   繁体   English

YII中的逻辑比较findAll()

[英]Logical Comparison in YII findAll()

I have data stored in database with date. 我已将数据与日期存储在数据库中。 Now I want to retrieve data of a particular time span for example from 1st March to 30th March. 现在,我想检索特定时间范围的数据,例如从3月1日到3月30日。

I have this query right now: 我现在有这个查询:

$tabCount = UserTabs::model()->findAll(array(
    'select'=>'id',
    'condition'=>'user_facebook_id=:user_facebook_id',
    'params'=>array(':user_facebook_id'=>Yii::app()->user->u_f_id),
));

Now I want to add a condition something like: 现在,我想添加一个条件,例如:

'date_added' > $start_Date AND 'date_added' < $end_Date

Please tell me how I can put this thing in the query. 请告诉我如何将这个东西放入查询中。

Any help would be highly appreciated. 任何帮助将不胜感激。

Thanks, Akif 谢谢,Akif

$tabCount = UserTabs::model()->findAll(array(
    'select'=>'id',
    'condition'=>'user_facebook_id=:user_facebook_id AND date_added BETWEEN :startDate AND :endDate',
    'params'=>array(':user_facebook_id'=>Yii::app()->user->u_f_id, ':startDate' => $start_Date, ':endDate' => $end_Date),
));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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