Level 20
You could do something like
$query = DB::('table_name')
->where(...)
->where(...);
$count = $query->count();
$data = $query->offset(0)->limit(50)->get();
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am doing something like:
$rows = DB('table_name')
->where.....
->where.....
.....
.....
....
->offset(0)
->limit(50)
->get()
I am integrating this with jquery serverside datatable. So, instead of repeating this whole code as follows to get count. Is there any other best way, so that I can stop myself from repeating things. As this where clasue has a very big list.
$count= DB('table_name')
->where.....
->where.....
.....
.....
....
->count();
You could do something like
$query = DB::('table_name')
->where(...)
->where(...);
$count = $query->count();
$data = $query->offset(0)->limit(50)->get();
Please or to participate in this conversation.