i have 100K record in users table how i can set limit for increase speed fetch data
return Datatables::of(DB::select('select * from users'))->make(true);
ok how i can post limit start , end in query ? from yaja ajax ??
return Datatables::of(DB::select('select * from users limit :from,:to',['from'=>0 , 'to'=>15]))->make(true);
i need from , to in query ??
@vahidalvandi use something like:
return Datatables::of(DB::table('users'))->make(true);
DB::select() returns collection while
DB::table() returns a query builder.
do it automatically fetch query with paginate before return to Datatables ??
@vahidalvandi yes, pagination is automatically applied.
do this create query builder ?
invoice::where('invoice_type','sale_in')->select('id','user_id','invoice_amount')->orderBy('id', 'desc')->get()
because if i remove get() search and order in table not Work
You need to remove ->orderBy('id', 'desc')->get() for order to work and create a builder. Inspect the ajax request to debug further if it fails.
i need order by desc !!
Then sorting will not work since it's fixed on id desc.
thank you
Most helpful comment
@vahidalvandi yes, pagination is automatically applied.