Reputation: 7938
I have a table in cakephp, containing box_id and quantity columns. If I run this query:
$a = $this->Order->query('SELECT SUM(quantity) AS q FROM order_boxes GROUP BY box_id ');
I get always a strange array:
Array
(
[0] => Array
(
[0] => Array
(
[q] => 242
)
)
[1] => Array
(
[0] => Array
(
[q] => 22
)
)
)
I would get a simple table (as SQL does indeed) like:
[box_id],[quantity]
Upvotes: 0
Views: 151
Reputation: 705
Try this
$a = $this->Order->query('SELECT box_id, SUM(quantity) AS q FROM order_boxes GROUP BY box_id ');
Upvotes: 1