- Notifications
You must be signed in to change notification settings - Fork 778
Open
Description
如果把查询语句进行分组查询,用Message::success('商品列表11',$wareList);返回的时候,就会有一个空的键,把分组去掉,就是正常的二维数组。
{ "msg": "商品列表11", "data": { "": [ //这里有个空的键名 { "id": 1, "title": "精品翡翠1号大师锻造手镯工艺极", "picture": "[\"/uploads/20191118/7893dd9beba39421db00fc20925e66bb.png\"]", "category_id": 2, "price": "200.00", "buyPrice": "0.01", "endTime": 1587006559, "label": "源头", "type": 2, "peoples": 877828, "pt_price": "0.00", "integral_val": "0.00", "sales": 1153, "bargain_price": "0.00" }, ] }, "code": 200 } 这是请求连接
http://47.99.133.238:18306/ware_list
。
这是我的sql语句
$wareList = DB::table('ware as w') ->leftJoin('ware_sku as ws', 'ws.ware_id', '=', 'w.id') ->leftJoin('ware_depot as d', 'd.id', '=' ,'w.depot_id') ->leftJoin('shop as s', 's.id','=', 'w.shop_id') ->limit(10) ->get([ 'w.id', 'w.title', 'w.picture', 'w.category_id', 'ws.market_price as price', 'ws.price as buyPrice', 'w.end_time as endTime', 'w.ware_label as label', 'ws.type', 'w.join_peoples as peoples', 'ws.pt_price as pt_price', 'ws.integral_val as integral_val', 'w.total_stock as sales', 'w.bargain_price' ]) ->groupBy('w.id, w.title, w.picture, w.end_time, ws.type') ->toArray(); // var_dump($wareList); // die; return Message::success('商品列表11',$wareList);Metadata
Metadata
Assignees
Labels
swoft: dbIssues for swoft db componentIssues for swoft db component