public function getPartners(){
$partner_id = Yii::$app->request->get('name');
$id = Yii::$app->request->get('id');
$sql = '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 name from pedigrees a where id=:partner_id)';
$partner = Pedigrees::findBySql($sql, [':id' => $id, ':partner_id' => $partner_id])->all();
return $partner;
}
<?php foreach ($model->partners as $part) {
echo Html::a( Html::encode($part->name, $part->id), Url::to(['pedigrees/view', 'id' => $part->id])) . '<br>';
//print $part->id;
} ?>