Based on thinkphp, the total amount in the Orders table by month
Data sheet: (Time: The timestamp of the month and the minute)
Implementation style:
Core code:
$list $m->where ($where) ->field ("SUM (' Stream_money ') as Stream_money,from_ Unixtime (Time, '%y-%m ') as months ") ->group (' months ') ->limit ($Page- FirstRow. ', '. $Page->listrows)// pagination, can be omitted ->order (' months desc ') ->select ();
Note: (implemented using native MySQL statements)
// instantiate an empty model with no corresponding data table $Dao = M (); $sql = "Select From_unixtime (Time, '%y%m ') months,count (ID) count,sum (stream_money) Stream_money from QP_DAP_ Stream WHERE type = 2 GROUP by months desc "; $res $Dao ->execute ($sql); // mainly for the execution of curd//return affecting the number of rows $lists = $Dao->query ($sql);
Reference: 1190000009304983?_ea=1885076
thinkphp Monthly Total order Amount