回答

收藏

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

技术问答 技术问答 224 人阅读 | 0 人回复 | 2023-09-14

好吧,所以我试着用它,所以我试着用它jQuery& F! T4 m+ Y  z! f4 W
DataTable(DataTables.net)从我的数据库中显示信息。我可以很好地显示整个表的注释,但我只想显示未读的注释。因此,我需要以某种方式包括它WHERE但我不知道实现这一目标的最好方法。( V2 c8 J3 U+ |5 p; m1 ?- y6 A
这是我目前展示整个表格的方式:
0 V" g. R6 x+ u9 t% N3 u6 }& G4 p// 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 '[url=profile.php?search='.$d.']'.$d."[/url]"; 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'4 ^& E: C: X1 P: z1 y
                                                               
0 `3 N6 R2 D0 C$ M. e4 c( m    解决方案:                                                               
) @8 m( b  G- ?% w                                                                您应该更改 DataTables的    默认功能做到这一点!
9 g" C0 Z% X9 G, S& J" Z使用此 ssp.class.php    定制类
9 ]& r2 J, U" k' L关联
% Q4 m  N$ X8 C# U) o就像下面的例子一样:# Y& _) |' e; @1 @  K4 h- v# m' ]' T6 n
require( 'ssp.class.php' );$where = "Status ='Unread'";echo json_encode(    SSP::simple( $_GET,$sql_details,$table,$primaryKey,$columns,$where ));如果设置$ where参数,则Custom类将在where子句中添加select语句!
& [$ X3 U$ Y3 f' G+ W6 i. E/ P$ N. f更新    :* Q; x; k2 n3 A9 g5 y
2015年DataTables添加复杂的方法4 |' H0 L9 X; @# o6 v4 Z- b. Y
可以在查询中设置新的内置方法where子句!
分享到:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则