I'm trying to include a new element on a array that is filled with a query result.
For example, I have an array called $event with $event['name']
, $event['date']
, $event['price']
.
Now, I want to add $event['category']
. This one is not declared on DB event table, but $event is an array of my code. It not depends of the DB event table, no?
So... how I can put $event['cateogory']
inside event in my Class code of CodeIgniter
?
I tried to put it directly, and the error show that "category" index is not defined.
$events = $this->Event_model->get_all_events();
foreach ($events as $event) {
$event['category'] = $this->Category_model->get_category($event['idCategory']);
}
$data{
'events' => $events,
}
$this->load->view('events_list',$data);
Thank you all