I am referring to this question here on stackoverflow, and I have the same problem, except that I use postgre database and can't seem to get this working.
This is my php function which is querying the database:
public function getCashData($id, $date)
{
if ($this->openConnection()){
$query = "SELECT * FROM cash_register (". $id .", '". $date ."');";
$result = pg_query($query);
if (!$result){
return false;
}
return pg_fetch_all($result);
}
}
I call this function like this:
$cashReport = getCashReport($id, $date);
$cashReport = array_map('utf8_encode' , $casaReport); //**note: please read below
echo json_encode($casaReport);
**This was working perfectly when I was returning only one row of result (and not all like now), but now when I'm returning an array of rows this array_map function (which I found in the above mentioned link) is not working as it expects an array and not an array of arrays.
Can you guys help me solve this problem?