我有一个对象Author、一个对象Post和一个对象CommentComment
BELONGS_TOPost
和Post
BELONGS_TOAuthor
。
我想获得帖子在'01-02-2015'
之后创建的所有评论,并且作者的生日在01-01-1980
之后。
我如何制定这些规则的条件/标准?
感谢
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
));
}
}