• <mark id="YVFdD"></mark>
    • <object id="YVFdD"><samp id="YVFdD"></samp><canvas id="YVFdD"><i id="YVFdD"><dt id="YVFdD"><cite id="YVFdD"></cite></dt></i><ul id="YVFdD"><option id="YVFdD"><output id="YVFdD"></output></option><ul id="YVFdD"></ul><area id="YVFdD"></area><sub id="YVFdD"><i id="YVFdD"><caption id="YVFdD"><nav id="YVFdD"></nav></caption></i></sub><colgroup id="YVFdD"></colgroup></ul><hgroup id="YVFdD"><select id="YVFdD"></select></hgroup><tfoot id="YVFdD"><area id="YVFdD"><input id="YVFdD"></input></area></tfoot></canvas></object>

      1. <form id="YVFdD"><th id="YVFdD"></th><object id="YVFdD"><video id="YVFdD"><td id="YVFdD"><colgroup id="YVFdD"></colgroup></td></video><form id="YVFdD"><blockquote id="YVFdD"><thead id="YVFdD"></thead></blockquote><fieldset id="YVFdD"></fieldset><fieldset id="YVFdD"></fieldset><colgroup id="YVFdD"><hgroup id="YVFdD"><dfn id="YVFdD"><button id="YVFdD"></button></dfn></hgroup></colgroup><style id="YVFdD"></style></form><tfoot id="YVFdD"><video id="YVFdD"></video></tfoot><p id="YVFdD"><source id="YVFdD"><strike id="YVFdD"></strike></source></p></object></form>
      2. tp分组group

        浏览:78 发布日期:2019/08/23 分类:功能实现
        tp分组group的函数配合使用 group_concat
        FROM_UNIXTIME
        FROM_UNIXTIME(unix_timestamp), FROM_UNIXTIME(unix_timestamp,format)是MySQL里的时间函数
        ,unix_timestamp可以是字段名,也可以直接是Unix 时间戳,format主要是将返回值格式化。
        若format已经给出,则结果的格式是根据format 字符串而定。

        MySQL中group_concat函数
        完整的语法如下:
        group_concat([DISTINCT] 要连接的字段 [Order BY ASC/DESC 排序字段] [Separator '分隔符'])

        实例:
        public function withdrawalsRecord($first = 0, $limit = 8)
        {
        $model=UserBill::where('uid',$this->userInfo['uid'])->where('category','now_money')->order('add_time desc')
        ->field(['FROM_UNIXTIME(add_time,"%Y-%m") as time','group_concat(id SEPARATOR ",") ids'])->group('time');
        $model=$model->where('type','extracts');
        $list=($list=$model->page((int)$first,(int)$limit)->select()) ? $list->toArray() : [];
        $data=[];
        foreach ($list as $item){
        $value['money']=$item['time'];
        $value['list']=UserBill::where('id','in',$item['ids'])->field(['FROM_UNIXTIME(add_time,"%Y-%m-%d %H:%i") as add_time','title','number','pm'])->order('add_time DESC')->select();
        array_push($data,$value);
        }
        return JsonService::successful($data);
        }
        我的开源商城3.0马上要发布 了,欢迎大家关注
        开源地址:http://github.crmeb.net/u/lsq
        评论( 相关
        后面还有条评论,点击查看>>