php - Accessing array index from joined table yii 2 -


hello have 2 tables schead , scstock joined , put in array looks this.

return static::find()           ->select('scstock.*')           ->leftjoin('schead', 'schead.trno = scstock.trno')           ->where([ 'schead.curriculumcode' => $currcode,             'schead.terms' => '1st',              'schead.styear' => 1])           ->asarray()           ->all(); 

now when go view can't access columns in schead table in case index section see screenshot below: enter image description here

the question how access columns in schead table in array index? , did in view

 <?php foreach($firstyearfirstterm $subjects):?>  <?= $subjects['section']?>  <?php endforeach; ?> 

but resulted in screenshot below. suggested when trying output section.

 foreach($subjects $subject){                                     echo $subject->schead->section;                               }  

but got this.

enter image description here

i need trying solve this, new yii framework.

you selecting columns scstock table. use following select statement:

->select(['scstock.*', 'schead.*']) 

Comments