I have an sql query which returns values. I would want to add new values with keys so that I can use it to my next controller which is these values doesn't come from the query result.
My Model:
$paymentDetails = $this->db->query($sql);
$payments = $paymentDetails->result();
//these are the values I wanted to add to the result for the $payments
$amountDue = 'Sample';
$change = 'Sample';
$result = array_merge($payments, array(
"AmountDue" => $amountDue,
"Change" => $change
));
if($result){
return $result;
}else{
return false;
}
I wonder why array_merge() doesn't work. In my view, values fetched from the SQL Query did returned, but the added (AmountDue and Change) is not found.
Please help me. Thank you so much! Ya'll be a big help for my project. :)