question 1:
1, the array of $array is as follows:
array (size=7)
1 => string "2018-09-21" (length=10)
2 => string "2018-09-22" (length=10)
3 => string "2018-09-23" (length=10)
4 => string "2018-09-24" (length=10)
5 => string "2018-09-25" (length=10)
6 => string "2018-09-26" (length=10)
7 => string "2018-09-27" (length=10)
The array of 2 and $list is as follows:
array (size=3)
0 =>
array (size=2)
"riqi" => string "2018-09-21" (length=10)
"count" => int 2
1 =>
array (size=2)
"riqi" => string "2018-09-26" (length=10)
"count" => int 2
2 =>
array (size=2)
"riqi" => string "2018-09-27" (length=10)
"count" => int 3
ask for help: how to php achieve the following effects
array (size=3)
0 =>
array (size=2)
"riqi" => string "2018-09-21" (length=10)
"count" => int 2
1 =>
array (size=2)
"riqi" => string "2018-09-22" (length=10)
"count" => int 0
2 =>
array (size=2)
"riqi" => string "2018-09-23" (length=10)
"count" => int 0
3 =>
array (size=2)
"riqi" => string "2018-09-24" (length=10)
"count" => int 0
4 =>
array (size=2)
"riqi" => string "2018-09-25" (length=10)
"count" => int 0
5 =>
array (size=2)
"riqi" => string "2018-09-26" (length=10)
"count" => int 2
6 =>
array (size=2)
"riqi" => string "2018-09-27" (length=10)
"count" => int 3
< hr >
question 2:
the existing sql is as follows:
select FROM_UNIXTIME(addtime,"%Y-%m-%d") as riqi, count(1) as count from order where FROM_UNIXTIME(addtime,"%Y-%m-%d") >= now() - interval 7 day group by FROM_UNIXTIME(addtime,"%Y-%m-%d")
how to achieve the following effects with one sentence of sql
array (size=3)
0 =>
array (size=2)
"riqi" => string "2018-09-21" (length=10)
"count" => int 2
1 =>
array (size=2)
"riqi" => string "2018-09-22" (length=10)
"count" => int 0
2 =>
array (size=2)
"riqi" => string "2018-09-23" (length=10)
"count" => int 0
3 =>
array (size=2)
"riqi" => string "2018-09-24" (length=10)
"count" => int 0
4 =>
array (size=2)
"riqi" => string "2018-09-25" (length=10)
"count" => int 0
5 =>
array (size=2)
"riqi" => string "2018-09-26" (length=10)
"count" => int 2
6 =>
array (size=2)
"riqi" => string "2018-09-27" (length=10)
"count" => int 3