回答

收藏

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

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

好吧,所以我试着用它,所以我试着用它jQuery0 E' v( h2 M0 r
DataTable(DataTables.net)从我的数据库中显示信息。我可以很好地显示整个表的注释,但我只想显示未读的注释。因此,我需要以某种方式包括它WHERE但我不知道实现这一目标的最好方法。
7 T7 ]' e' c& p" {! K: H6 N1 g2 C这是我目前展示整个表格的方式:
/ R9 W7 {6 d9 G; q# z// 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'. o7 V! S' T  c% O& k6 S
                                                               
: u2 p1 x5 [  Q7 P+ M2 U# ~    解决方案:                                                                ( j+ w0 x" N7 ~
                                                                您应该更改 DataTables的    默认功能做到这一点!6 v# B7 A' R9 F9 f$ m+ S+ c
使用此 ssp.class.php    定制类- I6 b: F# r# E" Q3 g( T
关联
9 N4 p) t3 G( j! t就像下面的例子一样:
* P7 v' Z2 k) _3 T9 n& S4 ?& Yrequire( 'ssp.class.php' );$where = "Status ='Unread'";echo json_encode(    SSP::simple( $_GET,$sql_details,$table,$primaryKey,$columns,$where ));如果设置$ where参数,则Custom类将在where子句中添加select语句!
' L& H, S/ G( _( i2 I, [更新    :% `- t$ v) b% i7 E8 G! C" Q
2015年DataTables添加复杂的方法
0 e7 k3 s6 v+ n2 |3 x' P' _可以在查询中设置新的内置方法where子句!
分享到:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则