EmailArchive Table:
id email_id to from
1 101 uk msm
2 102 uu avc
3 101 rk uk
4 103 xyz abc
5 104 xyz poi
6 104 abc xyz
7 101 xyz abc
Now in Yii I want record where email_id=101 I am using below code, but its not working.
$id =101;
$criteria = new CDbCriteria();
$criteria->addCondition("email_id < :email_id");
$comments = EmailArchive::model()->findAll($criteria, array(':email_id' => $id,));
Just to add some alternate, you could do like this also:
if you user $criteria, I recommend blow usage:
Try:
OR
OR
This is your safest way to do it:
Note that if you comment out the commented lines you get a way to add more filtering to your search.
After this it is recommend to check if there is any data returned like:
If you use
findAll()
, I recommend you to use this:Another simple way get by using findall in yii