表名 {{%admin_npsearch}} ‘{{%keywords}}‘ 类名 AdminNpsearch, Keywords,
1
public function getKeywords(){ return $this->hasOne(Keywords::className(),[‘id‘=>‘FKeywordID‘]); }//id是keywords表里
2AR里调用
AdminNpsearch的AR->joinWith(‘keywords‘)
3在视图里读取里
foreach ($models as $model) { echo $model->keywords->name; }
时间: 2024-10-04 20:53:01