我有三个数据库表:
产品(id,名称)
product_has_adv(产品,优势,排序,重要)
优势(身份证,文字)
在ProductModel中我定义了这个:
public function getAdvantages()
{
return $this->hasMany(AdvantageModel::className(), ['id' => 'advantage'])
->viaTable('product_has_advantage', ['product' => 'id']);
}
Run Code Online (Sandbox Code Playgroud)
我毫无问题地获得了优势.
但是现在我需要添加一个product_has_advantage.important = 1 clausel,并通过product_has_advantage-table中的sort-columen对优势进行排序.
我如何以及在哪里实现它?