ajeeeunni's avatar

Paginate stored procedure results

Hi, I'm using stored procedure in my project, Normally we can paginate query results with paginate() function but cannot do it in stored procedure. While am using this function getting "Call to a member function paginate() on a non-object" this error and my code is given below

$allUsers = DB::select('CALL choose_connections(?)', array(101))->paginate(3);

Can anybody help how to paginate stored procedure results?

0 likes
3 replies
bobbybouwmann's avatar

Are you sure the DB::select gives you anything back? Did you try to debug it with this?

$allUsers = DB::select('CALL choose_connections(?)', array(101))->get();

dd($allUsers);

Make sure you have the correct values first before you start the paginate!

ajeeeunni's avatar

$allUsers = DB::select('CALL choose_connections(?)', array(101))->paginate(3); When am executing this am getting this error "Call to a member function paginate() on a non-object"

if i execute $allUsers = DB::select('CALL choose_connections(?)', array(101))

It returns results without pagination

bobbybouwmann's avatar

Well you need to have a query builder to use paginate, so thi means you need to update your query to always return a query builder and then call paginate! You don't have a query builder right now

Please or to participate in this conversation.