thinkphp Monthly Total order Amount

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.