【发布时间】:2016-12-16 03:14:38
【问题描述】:
我正在使用DataTables jQuery plugin 以图表格式显示来自 mySQL 数据库的结果。我的服务器端配置如下:
// DB table to use
$table = 'Estimates';
// Table's primary key
$primaryKey = 'CreatedDate';
// 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' => 'Client', 'dt' => 0 ),
array( 'db' => 'EstimateNumber', 'dt' => 1 ),
array( 'db' => 'Status', 'dt' => 2 ),
array( 'db' => 'CurrentEstimateTotal', 'dt' => 3 ),
array( 'db' => 'CreatedDate', 'dt' => 4 )
);
// SQL server connection information
$sql_details = array(
'user' => 'root',
'pass' => 'root',
'db' => 'tm-charts',
'host' => 'localhost'
);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 )
);
这个处理主要是使用DataTables提供的简单的服务端处理模板which you can view here.
我的问题是:如何编辑此模板以仅显示 CreatedDate 列中没有 NULL 值的结果?
感谢您的帮助!
【问题讨论】:
-
如果我们知道
ssp类做了什么,我们可以告诉您构造一个从数据库中排除空值的查询? -
如果您有办法编辑查询,以便过滤结果然后找到它
-
@adeneo ssp.class.php 文件可以在 GitHub 上找到:github.com/DataTables/DataTables/blob/master/examples/…
-
那看看怎么用
filter ( $request, $columns, &$bindings )的方法说WHERE column IS NOT NULL
标签: php jquery mysql datatable datatables