我正在使用數據表列出數據作爲服務器端腳本。如何在Datatable php中連接兩個表或編寫自定義查詢?
// DB table to use
$table = 'enquiry';
// Table's primary key
$primaryKey = 'enquiry_id';
// Array of database columns which should be read and sent back to DataTables.
// The `db` parameter represents the column name in the database, while the `dt`
// parameter represents the DataTables column identifier. In this case simple
// indexes
$columns = array(
array(
'db' => 'enquiry_date',
'dt' => 0,
'formatter' => function($d, $row) {
return date('jS M y', strtotime($d));
}
),
array('db' => 'parent_name', 'dt' => 1),
array('db' => 'child_name', 'dt' => 2),
array('db' => 'mobile', 'dt' => 3),
array('db' => 'emirate', 'dt' => 4),
array('db' => 'remarks', 'dt' => 5),
array('db' => 'enquiry_status_id', 'dt' => 6),
);
// SQL server connection information
$sql_details = array(
'user' => 'root',
'pass' => '',
'db' => 'lsn',
'host' => ''
);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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('./server_side/scripts/ssp.class.php');
echo json_encode(
SSP::simple($_GET, $sql_details, $table, $primaryKey, $columns)
);
這是我的PHP服務器端腳本和工作非常好的單桌。
我想在列表行的同時連接兩個表。但是我找不到加入表格或編寫自定義查詢的選項。
如果有可能,我該如何連接表格?