I am doing a crontab that to email the users who haven't check our website for quite a long time.
I want to emails the user, for example, haven't on board for 1-2 weeks.
I have a column called "lastvist" in my tbl_user table.
But how can I write the filter command?
something like:
$users=Users::model()->findAllByAttributes->(...2weeks off the board since last visit....)
I store the lastvist via timestamp like this: 1343043800
Now i am doing something like this but i believe it's very low efficient since findAll is very expensive.
$now=time();
$users=Users::model()->findAll();
foreach($users as $user){
$intervel=$now-$user->lastvisit;
$days=intval($intervel/86400);
if($days > 14){
//send emails
}Any ideas would be appreciated...
Thanks so much!

Help
















