SELECT tbl_houses.style, tbl_houses.roomCount, tbl_residents.firstName, tbl_residents.lastName
FROM tbl_houses, tbl_residents
WHERE tbl_houses.houseID = tbl_residents.residentID
/*
* # Equivalent query using JOIN suggested by @KumarRakesh
* # Note: JOIN ... ON is a synonym for INNER JOIN ... ON
* # Using JOIN conforms to syntax spec'd by ANSI-92 https://dev59.com/jHNA5IYBdhLWcg3wmfO5#894855
*
* SELECT tbl_houses.style, tbl_houses.roomCount, tbl_residents.firstName, tbl_residents.lastName
* FROM tbl_houses
* JOIN tbl_residents ON tbl_houses.houseID = tbl_residents.residentID
*/
我该如何使用SSP让Datatables运行以上查询?
似乎server_processing.php仅接受一个表并且不支持自定义过滤(例如,WHERE
子句)。
// DB table to use
$table = 'datatables_demo';
// Table's primary key
$primaryKey = 'id';
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* If you just want to use the basic configuration for DataTables with PHP
* server-side, there is no need to edit below this line.
*/
require( 'ssp.class.php' );
echo json_encode(
SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )
);
然而,ssp.class.php 支持使用WHERE
过滤。我认为我需要修改ssp.class.php
,以强制使用我的WHERE
子句。
更新
找到了解决方案。有空时会发布。