Datatable icon indicating copy to clipboard operation
Datatable copied to clipboard

Query limit with skip and take with collection

Open techfuel-ts opened this issue 11 years ago • 4 comments

@Chumper Hello, I have situation where more 30,000 records are there. I have been trying to collection but it gives all records and which is too much time processing to get the result. I want to limit on first call as a 0 to 10, and so on. Is there anyway that i can pass skip and take with collection. return Datatable::collection(Mymodel::all(array('id', 'zip', 'neighbourhood', 'city', 'province', 'created_at', 'updated_at')))

Any examples really appreciated. Please help me...

techfuel-ts avatar Sep 06 '14 17:09 techfuel-ts

I would suggest to take the QueryEngine, it will only handle the needed amount of data. Is there a reason to use the CollectionEngine?

Chumper avatar Sep 15 '14 16:09 Chumper

Hi

i'm using QueryEngine with take() but it still showing all row in my database?

i set sDom like this:

$tblOptions["sDom"]= '<"top">rt<"row"<"col-xs-12">>';

to remove all top and bottom.

is this cause my issue?

thank you!

minh-hoang avatar Sep 29 '14 01:09 minh-hoang

Hi Chumper,

I checked bit its giving me an error on this line $this->originalBuilder = clone $builder;

it was something like $query_result = DB::table('tablename')->get()->take(10)->skip(10); return Datatable::query($query_result) ->make();

Do you have some sample example created on Queryengine, I tried to follow as per wiki but still facing issues?

sandeepts avatar Oct 01 '14 17:10 sandeepts

To be honest the queryEngine was just a part i did as an bonus because it seems easy to implement. However as the usage grows there are much more errors than i can handle for the query part. The problem is that the datatable script also tries to set take and skip and therefore overrides your setting.

May this will be a feature i can tackle with datatable 3.x but i am not sure yet how to handle a very dynamic query in datatable where you can put prefilters on it and stuff like that.

Chumper avatar Nov 25 '14 16:11 Chumper