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 Qt下使用tcp获取数据的详细操作
  • ¥15 idea右下角设置编码是灰色的
  • ¥15 全志H618ROM新增分区
  • ¥20 jupyter保存图像功能的实现
  • ¥15 在grasshopper里DrawViewportWires更改预览后,禁用电池仍然显示
  • ¥15 NAO机器人的录音程序保存问题
  • ¥15 C#读写EXCEL文件,不同编译
  • ¥15 MapReduce结果输出到HBase,一直连接不上MySQL
  • ¥15 扩散模型sd.webui使用时报错“Nonetype”
  • ¥15 stm32流水灯+呼吸灯+外部中断按键