Skip to content
Advertisement

Datatables + PHP: Server-Side Processing on Multiple Tables

How can I get Datatables Server-Side Processing script to work with a custom query? I need to select columns from multiple tables and have Datatables render them.

Datatables.net’s Server-Side Processing (SSP) with PHP is summarized here: https://datatables.net/examples/server_side/simple.html

I found this SO question, but the original poster never provided his solution. I don’t have sufficient reputation to ask him to provide more detail.

Here is my raw SQL without using Datatable’s SSP

JavaScript

How can I get Datatables to run queries off the above using SSP?

It appears server_processing.php only accepts 1 table and no custom filtering (i.e., WHERE clauses).

JavaScript

However, ssp.class.php does support filtering using WHERE. I’m thinking I need to modify ssp.class.php to force in my WHERE clause

UPDATE

Found a solution. Will post when I have free time.

Advertisement

Answer

TL;DR: I ended up using a modification of the original Datatables ssp.class.php called ssp.php implemented by Emran Ul Hadi: https://github.com/emran/ssp

His modification accepts JOIN, WHERE, GROUP BY and column aliases. Although the file hasn’t been updated in over a year, it still works with DataTables 1.12.x. I made some modifications to his version that increases its robustness and improves the documentation with clearer examples.

Will post my mods/updates here when I have a bit more time. Eventually I hope to put in a pull-request to get my updates into his repository.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement