php - How to pass a full MySQL query to Datatables? -
i trying use datatables.net build out table on website. have basic table generating ok using example , 1 table have complex query joins, clause, subquery, etc. , can't figure out how create table results.
their basic example looks this:
// db table use $table = 'tablenametoquery'; // table's primary key $primarykey = 'pk';
with @ end:
echo json_encode( ssp::simple( $_get, $sql_details, $table, $primarykey, $columns )
the mysql query looks along lines of:
select t1.col1, col2, col3, col4 table1 t1 left join table 2 t2 on t1.col1 = t2.col1 t2.col5 = 'complete'
server-side processing php script included in datatables distribution (examples/server_side/scripts/ssp.class.php
) simplistic , doesn't support joins , sub-queries right out of box.
emran ul hadi released modified ssp class supports need, please visit repository @ github.com/emran/ssp.
also in original ssp class in addition ssp::simple
there ssp::complex
method defined follows:
static function complex ( $request, $conn, $table, $primarykey, $columns, $whereresult=null, $whereall=null )
where $whereresult
condition apply result set , $whereall
condition apply queries. may use conditions ssp::complex
in $whereresult
and/or $whereall
parameters.