这是我在php中的代码。
$approveddata= "SELECT DATE AS DATE, company_id, count As Approved
FROM tbl_summary_order
WHERE DATE >= DATE( NOW( ) ) - INTERVAL 7
DAY AND STATUS =4
GROUP BY company_id, DATE( DATE )
ORDER BY DATE ASC "
while ($_row = $rsqueryapproveddata->read()) {
$list1[$_row['DATE']][$_row['company_id']] = $_row['Approved'];
}
我的输出为
"data": {
"2018-01-30": { "1": "10", "2": "5" },
"2018-01-31": { "1": "10" }
}
但是我需要一种格式来在每个内部数组中添加日期。
有点像下面的格式
data: [{ date: '2018-01-30', 1: 10, 2: 5, }, { date: '2018-01-31', 1: 10 }
答案 0 :(得分:1)
您可以使用包含当前日期值的关联数组初始化@PostMapping(value = "/rate/inc")
public Double incRate(User user) {
returnservice.incUserRate(user);
}
,然后在循环结束时使用array_values函数将结果作为数字数组获取:
$list1