I use cakephp and I have a model
$db = $this->getDataSource();
$result = $db->fetchAll(
'SELECT table1.id,
table1.title,
table1.buy_url,
table2.image_file as image,
table3.category_id as maincategory,
(table4.user_id = "71") AS isfavorite
FROM table1
INNER JOIN ...
LEFT JOIN ...
LEFT JOIN ...
where ...);
return $result;
I get this result:
{
"table1": {
"id": "132",
"title": "Awesome",
},
"table2": {
"image": "image_25398457.jpg"
},
"table3": {
"maincategory": "3"
},
"table4": {
"isfavorite": "1"
}
}
but I do not want to show the table names, I would prefer to get the result as follows:
{
"id": "132",
"title": "Awesome",
"image": "image_25398457.jpg"
"maincategory": "3"
"isfavorite": "1"
}
How can i achieve this?
Thank!
source
share