/** * @return \yii\db\ActiveQuery */ public function getComments() { return $this->hasMany(Comment::className(), ['section_id' => 'id']); }
public function getParent() { return $this->hasOne(Comment::className(), ['id' => 'parent_id']); }
/** * 关联关系,获取评论信息,按时间倒序排列 * @return ActiveQuery */ public function getComments() { return $this->hasMany(Comment::className(), ['post_id' => 'id'])->orderBy(Comment::tableName() . '.created_at DESC'); }
/** * 获取所有子评论 * @return \yii\db\ActiveQuery */ public function getSons() { return $this->hasMany(Comment::className(), ['parent_id' => 'id']); }
public function getComment() { return $this->hasOne(Comment::className(), ['id' => 'commentID']); }
/** * @return \yii\db\ActiveQuery */ public function getComments() { return $this->hasMany(Comment::className(), ['post_id' => 'id'])->where('status = ' . Comment::STATUS_ACTIVE)->orderBy('id'); }
/** * @return \yii\db\ActiveQuery */ public function getCommentsPassedBad() { return $this->hasMany(Comment::className(), ['product_id' => 'id'])->where(['status' => Status::STATUS_ACTIVE, 'star' => 1])->orderBy(['created_at' => SORT_DESC]); }
/** * @return \yii\db\ActiveQuery */ public function getChildComments() { return $this->hasMany(Comment::className(), ['parent' => 'id']); }