zoukankan      html  css  js  c++  java
  • laravel 先orderBY再groupby,导致分组后的排序不正确

     //联系过我的经纪人
                $appletChats=$this->AppletChat->orderBy('created_at','desc')->where([['user_id',$param['user_id']],['source',2]])
                    ->get(['send_user','created_at'])->toArray();
                //  二维数组去重
                $res = array();
                foreach ($appletChats as $value){
                    if (!empty($value['send_user'])) {
                        if (!isset($res[$value['send_user']])) {
                            $res[$value['send_user']] = $value;
                        }
                    }
                }
                dd($res);
    

      

  • 相关阅读:
    day_13
    day_12
    day_11
    day_10
    day_09
    day_08
    day_07
    day_06
    cmder 基本配置和使用
    php自动加载
  • 原文地址:https://www.cnblogs.com/lxwphp/p/15453348.html
Copyright © 2011-2022 走看看