秋生沧韵 发表于 2023-9-14 12:20:44

如何通过ssp.class.php数据表使用'WHERE'子句

好吧,所以我试着用它,所以我试着用它jQuery
DataTable(DataTables.net)从我的数据库中显示信息。我可以很好地显示整个表的注释,但我只想显示未读的注释。因此,我需要以某种方式包括它WHERE但我不知道实现这一目标的最好方法。
这是我目前展示整个表格的方式:
// DB table to use$table = 'Notes';// Table's primary key$primaryKey = 'CID';// 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' => 'CID','dt' => 0 ),array(   db          => 'CID',            'dt          => formatter' => function( $d,$row ()()()()()return ''.$d.""; array( 'db' => 'Title','dt' => 1 ),array( 'db' => 'Name', 'dt' => 2 ),array(    'db          => 'Date dt          => 3、formatter' => function( $d,$row ()()()()()return date( 'jS M y',strtotime($d));       )SQL server connection information$sql_details = array('user' => '*DB_USER*','pass' => '*Password*','db'   => '*DatabaseName*','host' => 'localhost');require( 'ssp.class.php' );echo json_encode(    SSP::simple( $_GET,$sql_details,$table,$primaryKey,$columns ));我需要相当于 SELECT * FROM Notes WHERE Status ='Unread'
                                                               
    解决方案:                                                               
                                                                您应该更改 DataTables的    默认功能做到这一点!
使用此 ssp.class.php    定制类
关联
就像下面的例子一样:
require( 'ssp.class.php' );$where = "Status ='Unread'";echo json_encode(    SSP::simple( $_GET,$sql_details,$table,$primaryKey,$columns,$where ));如果设置$ where参数,则Custom类将在where子句中添加select语句!
更新    :
2015年DataTables添加复杂的方法
可以在查询中设置新的内置方法where子句!
页: [1]
查看完整版本: 如何通过ssp.class.php数据表使用'WHERE'子句