в таком варианте выходит ошибка Getting unknown property: app\controllers\PedigreesController::partner
public function actionView($id)
{
$query = "SELECT dam as partner_id FROM pedigrees WHERE (sire=$id and dam<>0) group by dam union SELECT sire as partner_id FROM pedigrees WHERE (dam=$id and sire<>0) group by sire order by (select a.name from pedigrees a where pedigrees_id=partner_id)";
$partner = Pedigrees::findBySql($query)->all();
return $this->render('view', [
'model' => $this->findModel($id),
'partner' => $this->partner,
]);
}
вывод:
<?php foreach ($partners as $name) {
echo $name->name . '<br>';
}?>