<!-- 连表model -->
class Ls extends ActiveRecord
{
//重命名表名 %为前缀名
public static function tableName()
{
return '{{%news}}';
}
//设置主键(当前model不为主键值)
// public static function primaryKey(){
// return ['key'=>'id'];
// }
public function getNews()
{
return $this->hasOne(cnt::className(),['id' => 'id']);
}
public function getCategory()
{
return $this->hasOne(ly::className(),['catid'=>'catid']);
}
}