首先我們要明確我們需要查詢的表member表。
再次,明確查詢的關鍵,當新增人員時候,create_time字段來存儲數據產生的時間。create_time 的存儲格式是什麼。可能是時間戳,也可能是年月日時間格式。
接下來我們進行邏輯的實現。
首先我們要獲取今天是本週的周幾:
$week_day = date("w");
獲取到周幾以以後,我們可以用for循環來獲取週一到今天的增人數。
for ($i=$w-1;$i>=0;$i--){
因為本人存儲create_time 使用的是日期格式
$date = date('Y-m-d',strtotime('-'.$i.' day'));
$data[]=db('member') ->where('create_time',$date)->count('id');
}
return $data;
這樣就可以