I have an object Author, an object Post and an object Comment. Comment
BELONGS_TO Post
and Post
BELONGS_TO Author
.
I want to get all Comments which the Post created after the '01-02-2015'
AND Author's birthday is after 01-01-1980
.
How can I develop condition/criteria for these rules?
Thanks
class Comment extends CActiveRecord {
public function search(){
$criteria = new CDbCriteria;
$criteria->together = true;
$criteria->with = array(
'post' => array(
'condition' => "created>='2015-02-01'",
'joinType' => "INNER JOIN",
'with' => array(
'author' => array(
'condition' => "birthday>='1980-01-01'",
'joinType' => "INNER JOIN",
)
)
)
);
return new CActiveDataProvider($this, array(
'criteria' => $criteria
));
}
}