我在 PHP 中有以下查询:
$stmt = $conn->prepare('SELECT
date,
avg(sells) as sells
FROM `table` WHERE product_id = :id group by date having count(id) > 1');
$stmt->execute(array('id' => $product));
$res = $stmt->fetchAll(PDO::FETCH_ASSOC);
正如预期的那样,这返回了我:
array(2) {
[0]=> array(2) {
["date"]=> "2013-1-11" ["sells"]=> "73.5000"
}
[1]=> array(2) {
["date"]=> "2013-1-11" ["sells"]=> "77.0000"
}
}
无论如何,我可以在不使用 php 循环的情况下获得以下输出?
array(2) {
[0]=> array(2) {
"2013-1-11",
"73.5000"
}
[1]=> array(2) {
"2013-1-11",
"77.0000"
}
}