How could I be able to find multiple records in a table using single instance of a model in the infamous Yii Framework for PHP?
I have a dates column:
[dates]
2011-06-29
2011-06-30
2011-07-01
2011-07-02
2011-07-03
And suppose I have a search criteria witch is a date range:
start search from: 2011-06-29
end search at: 2011-07-03
And grab all those records for comparring, or to tell user that those records already exist in the table.
How is this achivable with Yii Framework, enpowered with it’s CActiveRecord, CDbCriteria, etc built-in classes?
Assuming you have a
CActiveRecordsubclass namedYourModel, and the database table has a column nameddates, you would do:The parameter to
findAllcan also be aCDbCriteriaobject; you would set the properties having the same name as the array keys in the above example.