Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dede02830's avatar

[L5] - Paginate fail after update

Hello,

i have a problem with my pagination after a composer update.

Before i have in my controller:

$points = \DB::table('Point')
                ->leftjoin('Network', 'Network.networkID', '=', 'Point.networkID')
                ->leftjoin('TPoint', 'TPoint.tpointID', '=', 'Point.tpointID')
                ->paginate($this::NBRPARPAGES, array('Point.pointID', 'Point.active', 'Point.name', 'Network.label as netlab', 'TPoint.label as tplab'));
        

and in my view :

{!! str_replace('/?', '?', $points->render()) !!}

And this is correct, but now after update i have this error :

QueryException in Connection.php line 624: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' `Point`.`active`, `Point`.`name`, `Network`.`label` as `netlab`, `TPoint`.`labe' at line 1 (SQL: select count(`Point`.`pointID`, `Point`.`active`, `Point`.`name`, `Network`.`label` as `netlab`, `TPoint`.`label` as `tplab`) as aggregate from `Point` left join `Network` on `Network`.`networkID` = `Point`.`networkID` left join `TPoint` on `TPoint`.`tpointID` = `Point`.`tpointID`)

The problem is the array in my paginate i think.

Error :



    in Connection.php line 624
    at Connection->runQueryCallback('select count(`Point`.`pointID`, `Point`.`active`, `Point`.`name`, `Network`.`label` as `netlab`, `TPoint`.`label` as `tplab`) as aggregate from `Point` left join `Network` on `Network`.`networkID` = `Point`.`networkID` left join `TPoint` on `TPoint`.`tpointID` = `Point`.`tpointID`', array(), object(Closure)) in Connection.php line 580
    at Connection->run('select count(`Point`.`pointID`, `Point`.`active`, `Point`.`name`, `Network`.`label` as `netlab`, `TPoint`.`label` as `tplab`) as aggregate from `Point` left join `Network` on `Network`.`networkID` = `Point`.`networkID` left join `TPoint` on `TPoint`.`tpointID` = `Point`.`tpointID`', array(), object(Closure)) in Connection.php line 297
    at Connection->select('select count(`Point`.`pointID`, `Point`.`active`, `Point`.`name`, `Network`.`label` as `netlab`, `TPoint`.`label` as `tplab`) as aggregate from `Point` left join `Network` on `Network`.`networkID` = `Point`.`networkID` left join `TPoint` on `TPoint`.`tpointID` = `Point`.`tpointID`', array(), true) in Builder.php line 1377
    at Builder->runSelect() in Builder.php line 1367
    at Builder->getFresh(array('*')) in Builder.php line 1354
    at Builder->get() in Builder.php line 1432
    at Builder->getCountForPagination(array('Point.pointID', 'Point.active', 'Point.name', 'Network.label as netlab', 'TPoint.label as tplab')) in Builder.php line 1391
    at Builder->paginate('30', array('Point.pointID', 'Point.active', 'Point.name', 'Network.label as netlab', 'TPoint.label as tplab')) in DotsController.php line 60
    at DotsController->index()
    at call_user_func_array(array(object(DotsController), 'index'), array()) in Controller.php line 246
    at Controller->callAction('index', array()) in ControllerDispatcher.php line 162
    at ControllerDispatcher->call(object(DotsController), object(Route), 'index') in ControllerDispatcher.php line 107
    at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 141
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Authenticate.php line 47
    at Authenticate->handle(object(Request), object(Closure)) in Pipeline.php line 125
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 101
    at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 108
    at ControllerDispatcher->callWithinStack(object(DotsController), object(Route), object(Request), 'index') in ControllerDispatcher.php line 67
    at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\DotsController', 'index') in Route.php line 204
    at Route->runWithCustomDispatcher(object(Request)) in Route.php line 134
    at Route->run(object(Request)) in Router.php line 701
    at Router->Illuminate\Routing\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 141
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 101
    at Pipeline->then(object(Closure)) in Router.php line 703
    at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 670
    at Router->dispatchToRoute(object(Request)) in Router.php line 628
    at Router->dispatch(object(Request)) in Kernel.php line 214
    at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 141
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in VerifyCsrfToken.php line 43
    at VerifyCsrfToken->handle(object(Request), object(Closure)) in VerifyCsrfToken.php line 19
    at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 125
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 55
    at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 125
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 61
    at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 125
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 36
    at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 125
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 40
    at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 125
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
    at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 125
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 101
    at Pipeline->then(object(Closure)) in Kernel.php line 115
    at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 84
    at Kernel->handle(object(Request)) in index.php line 53

How i can resolve them without use a custom pagination if possible ??

Thank

0 likes
4 replies
bobbybouwmann's avatar

The problem is not in your pagination... It gives you a mysql syntax error, start there

dede02830's avatar

@bobbybouwmann

Yes, the problem come to the array.

Also i delete all array in the

->paginate($this::NBRPARPAGES, array('Point.pointID', 'Point.active', 'Point.name', 'Network.label as netlab', 'TPoint.label as tplab'));

because the problem is here and when i delete this paginate run.

however i need this array else i have many fields useless and some have the same name and replace the other...

bobbybouwmann's avatar
Level 88

Why don't you turn it arround?

$points = \DB::table('Point')
        ->select('Point.pointID', 'Point.active', 'Point.name', \DB::raw('Network.label as netlab'), \DB::raw('TPoint.label as tplab'))
                ->leftjoin('Network', 'Network.networkID', '=', 'Point.networkID')
                ->leftjoin('TPoint', 'TPoint.tpointID', '=', 'Point.tpointID')
                ->paginate($this::NBRPARPAGES);

Note: I also updated it to DB::raw because I like it more that way, but I believe it works without the DB::raw stuff

1 like
dede02830's avatar

yes, very good @bobbybouwmann this run now :)

yes, all my query are created with where and get or paginate, i don't think to use select ... And before update this run also i dont think to change my query ^^

Thank ;)

Please or to participate in this conversation.