Reputation: 6987
I have a statement similar to the one below, in Laravel:
$tiles = Tile::with('comments', 'user', 'category', 'ratings')
->take($startRow, 15)
->get();
return Response::json($tiles);
But this just limited the number of rows returned and did not take into account the offset. I tried replacing the take
statement with select(DB::raw('LIMIT(' . $startRow . ',15)'))
but this produced a SQL syntax error.
So how can I add a LIMIT :startRow, 15
clause to the end of my SQL query using Laravel's query builder?
Upvotes: 0
Views: 2640
Reputation: 467
I suggest you try this. the skip()
method is for offsets
$tiles = Tile::with('comments', 'user', 'category', 'ratings')
->take(15)
->skip($startRow)
->get();
return Response::json($tiles);
Read more about skip.
Upvotes: 2