Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/240.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel/雄辩的分页返回了太多的页面,有些页面是空的_Php_Laravel_Eloquent - Fatal编程技术网

Php Laravel/雄辩的分页返回了太多的页面,有些页面是空的

Php Laravel/雄辩的分页返回了太多的页面,有些页面是空的,php,laravel,eloquent,Php,Laravel,Eloquent,我有以下疑问: return Calls::select(DB::raw("ph_n.`desc`, ph_s.StageName, Calls.PatID, Calls.CallTime, Calls.ApptDate, Calls.Name, ph.Response, Calls.Physician, r.StatusDesc, ph_s.DaysToNextStage, ph_e.ph_eventid, ph_e.EventName")) ->join('PopHea

我有以下疑问:

return Calls::select(DB::raw("ph_n.`desc`, ph_s.StageName, Calls.PatID, Calls.CallTime, Calls.ApptDate, Calls.Name, ph.Response, Calls.Physician, r.StatusDesc, ph_s.DaysToNextStage, ph_e.ph_eventid, ph_e.EventName"))
        ->join('PopHealth as ph', function($join){
            $join->on('Calls.PatID', '=', 'ph.PatID');
            $join->on('Calls.Login', '=', 'ph.Login');
        })
        ->join('Response as r', 'ph.Response', '=', 'r.RespID')
        ->join('PopHealth_stages as ph_s', 'ph.ph_eventid', '=', 'ph_s.ph_eventid')
        ->join('PopHealth_events as ph_e', 'ph.Login', '=', 'ph_e.Login')
        ->join('PopHealth_notify as ph_n', function($join){
            $join->on('r.status', '<=', 'ph_n.RangeUpper');
            $join->on('r.status', '>=', 'ph_n.RangeLower');
        })
        ->where('Calls.Login', 'demo')
        ->distinct()->take(100)
        ->paginate(10);
return Calls::select(DB::raw(“ph_n.`desc`,ph_.StageName,Calls.PatID,Calls.CallTime,Calls.ApptDate,Calls.Name,ph.Response,Calls.medicine,r.StatusDesc,ph_.DaysToNextStage,ph_.ph_eventid,ph_e.EventName”))
->join('PopHealth as ph',函数($join){
$join->on('Calls.PatID'、'='、'ph.PatID');
$join->on('Calls.Login'、'='、'ph.Login');
})
->join('Response as r','ph.Response','=','r.RespID')
->加入('PopHealth'阶段为ph_s'、'ph.ph_eventid'、'='、'ph_.ph_eventid')
->join('PopHealth'事件,如ph_e'、'ph.Login'、'='、'ph_e.Login')
->join('PopHealth\u notify as ph\u n',函数($join){
$join->on('r.status'、'='、'ph_n.RangeLower');
})
->其中('Calls.Login','demo')
->distinct()->take(100)
->分页(10);
它返回了400多页,很多页都是空的。网上没有出现这个问题。有线索吗

编辑:

dd(DB::getQueryLog());抛出以下SQL语句:

array(4) { [0]=> array(3) { ["query"]=> string(70) "select * from `PopHealth_events` where `Login` = ? and `IsDeleted` = ?" ["bindings"]=> array(2) { [0]=> string(4) "demo" [1]=> string(1) "0" } ["time"]=> float(196.17) } [1]=> array(3) { ["query"]=> string(103) "select distinct `ph_eventid`, `EventName` from `PopHealth_events` where `Login` = ? and `IsDeleted` = ?" ["bindings"]=> array(2) { [0]=> string(4) "demo" [1]=> string(1) "0" } ["time"]=> float(217.22) } [2]=> array(3) { ["query"]=> string(505) "select count(*) as aggregate from `Calls` inner join `PopHealth` as `ph` on `Calls`.`PatID` = `ph`.`PatID` and `Calls`.`Login` = `ph`.`Login` inner join `Response` as `r` on `ph`.`Response` = `r`.`RespID` inner join `PopHealth_stages` as `ph_s` on `ph`.`ph_eventid` = `ph_s`.`ph_eventid` inner join `PopHealth_events` as `ph_e` on `ph`.`Login` = `ph_e`.`Login` inner join `PopHealth_notify` as `ph_n` on `r`.`status` <= `ph_n`.`RangeUpper` and `r`.`status` >= `ph_n`.`RangeLower` where `Calls`.`Login` = ?" ["bindings"]=> array(1) { [0]=> string(4) "demo" } ["time"]=> float(192.68) } [3]=> array(3) { ["query"]=> string(694) "select distinct ph_n.`desc`, ph_s.StageName, Calls.PatID, Calls.CallTime, Calls.ApptDate, Calls.Name, ph.Response, Calls.Physician, r.StatusDesc, ph_s.DaysToNextStage, ph_e.ph_eventid, ph_e.EventName from `Calls` inner join `PopHealth` as `ph` on `Calls`.`PatID` = `ph`.`PatID` and `Calls`.`Login` = `ph`.`Login` inner join `Response` as `r` on `ph`.`Response` = `r`.`RespID` inner join `PopHealth_stages` as `ph_s` on `ph`.`ph_eventid` = `ph_s`.`ph_eventid` inner join `PopHealth_events` as `ph_e` on `ph`.`Login` = `ph_e`.`Login` inner join `PopHealth_notify` as `ph_n` on `r`.`status` <= `ph_n`.`RangeUpper` and `r`.`status` >= `ph_n`.`RangeLower` where `Calls`.`Login` = ? limit 10 offset 0" ["bindings"]=> array(1) { [0]=> string(4) "demo" } ["time"]=> float(198.18) } }
array(4){[0]=>array(3){[“query”]=>string(70)“从`PopHealth`事件中选择*其中`Login`=?和`IsDeleted`=?”[“bindings”]=>array(2){[0]=>string(4)“demo”[1]=>string(1)“time”=>float(196.17)}[1]=>array(3){[“query”=>string(103)“从` PopHealth`事件'中选择不同的`ph_eventid`、`EventName`,其中`Login`=?和`IsDeleted`=?”[“bindings”=>array(2){[0]=>string(4)“demo”[1]=>string(1)“0”}[“time”]=>float(217.22)}[2]=>array(3){[“query”=>string(505)”选择计数(*)从'Calls`internal join`pophhealth`as`ph`on`Calls`.'PatID`=`ph`.'Login`=`ph`.'Login`internal join`Response`as`r`on`ph`.'RespID`.'internal join`pophhealth`stages`ph`.'ph`.'u eventid`=`ph`s`.'ph`ph`eventid` internal join`pophhealth`.'e` on`ph`.'Login`.'ph`.`phu`.'e`er加入'PopHealth'u notify`作为'r'上的'ph\u n'。'status`='ph\u n`.'RangeLower`where`Calls`.'Login`=?“[“bindings”=>array(1){[0]=>string(4)“demo”}[“time”]=>float(192.68)}[3]=>array(3){[“query”=>string(694)”选择不同的ph_n.`desc`、ph_s.StageName、Calls.PatID、Calls.CallTime、Calls.ApptDate、Calls.Name、ph.Response、Calls.Medicine、r.StatusDesc、ph_s.DaysToNextStage、ph_e.ph_eventid、ph_e.EventName from`Calls`Internal join`PopHealth`为`ph`Calls``.`Response`=`r`.`RespID`internal join`pophhealth`u stages`ph`u-s`ph`u-eventid`=`ph`u-s`.`ph`u-eventid`internal join`pophhealth`u-events`as`ph`.`Login`=`ph`e`.`Login` pophhealth`u-notify` as`ph`n`r`.`status`=`ph`n`.`RangeLower`Calls`.`Login`.`Login`.`Login``限制10偏移量为0`.[`s`=`s=`bindings`=>string=>0'>演示“}[“时间”]=>float(198.18)}
SQL限制了结果。

您解决了这个问题吗

我面临着同样的问题,我发现罪魁祸首是,当laravel的paginate查询DB以查找元素总数时,没有考虑到distinct,因此项目总数要大得多

这里有一个答案:

简言之,您必须创建自己的分页