On my controller, i want to foreach another models to add the result in the existing array.
My controller:
public function index()
{
$getConcerts_previous = $this->concert_model->getAllConcerts('previous');
foreach($getConcerts_previous as $concert) {
$hallData = $this->hall_model->getHallbyID($concert->cHall_ID);
$concert->hHall_ID = isset($hallData) ? $hallData->hID : 'No data';
}
$this->render_layout('concerts/index', $this->data);
}
Actualy when i @varp_dump my '$getConcerts_previous' on my view, I have:
public 'cID' => string '45' (length=2)
public 'cBand_ID' => string '8' (length=1)
public 'cDate' => string '2018-06-22' (length=10)
And i want to know how add on this var dump for example
public 'cID' => string '45' (length=2)
public 'cBand_ID' => string '8' (length=1)
public 'cDate' => string '2018-06-22' (length=10)
public 'hHall_ID' => string '1' (length=1)
My database:
Concerts: cID | cName | cPlaceType | cPlaceID
Festivals: fID | fName
Halls: hID | hName
If cPlaceType = 1, select festival with cPlaceID, If cPlaceType = 2, select hall with cPlaceID,
hHall_IDto the first var_dump?$hallDatainto$getConcerts_previous?concert_model->getAllConcerts(){..}