'在数组上调用成员函数paginate()'多个连接表发生错误

时间:2019-05-15 04:14:16

标签: php mysql laravel-5.1 laravel-query-builder laravel-paginate

Laravel查询构建器需要从多个联接表分页。

我尝试了多种方式对这个查询进行分页。但是什么都没有。

Controller.php

$ord_heds = DB::select('select d.family, d.category, d.product_img, d.ord_ref, m.min_qty, m.max_qty, t.qty, t.value, SUM(replace(d.value,",","")) as ordval, SUM(replace(d.qty,",","")) as Tord_qty, COUNT(d.qty) as no_of_items_ordered, (select COUNT(itemCode) as mcount from item_statuses where '.'s'.$siteG.' ="'.$site.'" and itemCode in (select itemCode FROM items WHERE category=d.category and brand=d.family)) as manCount, (select COUNT(itemCode) as mcount1 from item_statuses where '.'s'.$siteG.' ="'.$site.'" and itemCode in (select itemCode FROM items WHERE category=d.category and brand=d.family and itemCode in (select itemcode FROM ord_dets where ord_dets.site = "'.$ordSite.'"))) as ordManCount FROM ord_dets d JOIN ord__heds h ON d.ord_ref = h.id INNER JOIN min__maxes m ON d.category = m.category AND d.site = m.site AND d.scode = m.season INNER JOIN targets t ON d.category = t.category AND d.family = t.brand AND d.month = t.month AND d.year = t.year AND d.site = t.site WHERE h.month = "'.$date[1].'" AND h.year = "'.$date[0].'" AND h.site = "'.$ordSite.'" GROUP BY d.family, d.category, d.product_img, d.ord_ref, m.min_qty, m.max_qty, t.qty, t.value');

$pag = $ord_heds->paginate(10);

dd($pag);

以上代码导致错误“ FatalThrowableError调用数组上的成员函数paginate()”。

0 个答案:

没有答案