我有一个对象作者,一个对象Post和一个对象Comment。 Comment
BELONGS_TO Post
和 Post
BELONGS_TO Author
我希望获得帖子在'01-02-2015'
和作者生日之后创建的所有评论都在01-01-1980
之后。
我如何制定这些规则的条件/标准?
由于
答案 0 :(得分:1)
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
));
}
}