简体   繁体   中英

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.

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

$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),
));

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