/**
* @return \yii\db\ActiveQuery
*/
public function getNews()
{
return $this->hasMany(News::className(), ['category' => 'id'])->orderBy('created_at DESC');
}
$news = Category::findOne($category_id)->news;
/**
* @return \yii\db\ActiveQuery
*/
public function getNews()
{
return $this->hasMany(News::className(), ['category' => 'id'])->orderBy('created_at DESC');
}
$news = Category::findOne($category_id)->news;
本文标题:yii对oneToMany关联对象进行排序
本文链接:https://www.haomeiwen.com/subject/habudttx.html
网友评论