douyinzha5820 2016-08-09 22:34
浏览 79
已采纳

如何仅显示指定列中没有NULL值的结果?

I am using the DataTables jQuery plugin to display results from a mySQL database in a chart format. My server-side configuration for this is below:

// 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 )
);

This processing is largely using the simple server-side processing template provided by DataTables, which you can view here.

My question is: How can I edit this template to only display results that do not have a NULL value in the CreatedDate column?

Thanks for your help!

  • 写回答

2条回答 默认 最新

  • douyiyang6317 2016-08-11 18:40
    关注

    I got it working!

    Here is the answer:

    echo json_encode(
    SSP::complex( $_GET, $sql_details, $table, $primaryKey, $columns, null, "CreatedDate IS NOT NULL" )
    );
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 win11笔记本系统出了问题
  • ¥20 找驱动QTR2774-SU-IBM版本驱动
  • ¥15 NeRF的代码复现以及人工智能入门
  • ¥15 centos如何做一个可以让ikuai连接的openvpn
  • ¥15 Protege 中的Entities下面的界面删除了如何复原
  • ¥15 scrapy爬虫求帮
  • ¥15 imageEnView绘图问题
  • ¥15 关于#python#的问题:您好可以加您一下联系方式吗,在复现的时候确实有点问题难以解决
  • ¥15 联想电脑重装系统时无法发现硬盘
  • ¥15 MATLAB与UR10e实体机械臂建立通讯