How to query the 5 pieces of data starting with a specified ID in laravel5.2?
ringa_lee
ringa_lee 2017-05-16 16:48:32
0
2
417

For example, there are a total of 10 pieces of data with IDs 1-10, and now I want to query the 5 pieces of data after the specified ID based on the passed ID,

For example, if the incoming id is 1, the data with id 1,2,3,4,5 will be queried.
If the id is 3, the id will be 3,4,5,6. 7 data

How to write?Thank you

ringa_lee
ringa_lee

ringa_lee

reply all(2)
大家讲道理

Take the users table as an example:

\DB::table('users')
    -> where('id', '>=', $id)
    -> orderBy('id')
    -> take(5)
    -> get();
小葫芦

where id >=1 and id <=5
where id >=3 and id <=7

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template