Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit query is not working with Datatable #30

Open
DhPandya opened this issue Dec 8, 2022 · 0 comments
Open

Limit query is not working with Datatable #30

DhPandya opened this issue Dec 8, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@DhPandya
Copy link

DhPandya commented Dec 8, 2022

Describe the bug
Suppose I want to display the latest 10 orders on the dashboard and I added a limit(10) to my query then it's now working with the datatables. It is always showing all records instead of the limit. It always takes the length of the datatable rendered Dropdown. Here it should work if I'm limiting the results to 10 then it should show only 10 records.

Your code

$builder = $this->order_model->select('orders.id,company_name,order_no,order_datetime,empty_date_called,customer_id,booking_no,steamship_id,container_no,size_id,pickup_return_location,order_status,terminate,steamships.name as steamship_name,size_id,size,is_void,(CASE WHEN order_type=3 THEN "Domestic" WHEN order_type=2 THEN "Export" WHEN order_type=1 THEN "Import" WHEN order_type=4 THEN "Trailer" ELSE "N/A" END) as order_type_text,chassis,chassis_id')
            ->join('customers', 'customers.id=orders.customer_id', 'left')
            ->join('steamships', 'steamships.id=orders.steamship_id', 'left')
            ->join('containersizes', 'containersizes.id=orders.size_id', 'left')
            ->join('(SELECT id,chassis from ' . db_prefix() . 'chasses) as tblchasses', 'tblchasses.id=orders.chassis_id', 'left')
            ->limit(10);

$datatable = DataTable::of($builder);
return $datatable->toJson(true);

Screenshots
If applicable, add screenshots to help explain your problem.

Version (please complete the following information):

  • PHP Version:8.1
  • CodeIgniter version: 4.2.10
  • Library version:0.6.1
@DhPandya DhPandya added the bug Something isn't working label Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant