I have data that is a result from a query. I would like to insert some array variables of it. I have ID's then I tried to make a query and insert the query into a variable.
I have a data like these as a result of my query:
Array ( [0] => stdClass Object ( [id] => 27 [message] => {"msg_subject":"hello","msg_content":"world"} [date] => 2020-05-24 15:03:40 [parent_msg] => 0 ) )
now I want to insert a data inside the array object like the final result would be this:
Array ( [0] => stdClass Object ( [id] => 27 [message] => {"msg_subject":"Hooy","msg_content":"Ok ra?"} [date] => 2020-05-24 15:03:40 [parent_msg] => 0 ) [read] => 0 )
Here is what I've tried:
foreach($query->result_array() as $row){
$this->db->select('mp.*');
$this->db->from('message_tbl mp');
$this->db->join('message_tbl mc', 'mc.parent_msg = mp.id');
$this->db->where('mc.id',$row['msg_id']);
$data = $this->db->get()->result();
array_push($data,$row['read']);
}
print_r($data);
then when I printed my data Here is the output:
Array ( [0] => stdClass Object ( [id] => 27 [message] => {"msg_subject":"Hooy","msg_content":"Ok ra?"} [date] => 2020-05-24 15:03:40 [parent_msg] => 0 ) [1] => 0 )