objects.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  3. * Easy set variables
  4. */
  5. // DB table to use
  6. $table = 'datatables_demo';
  7. // Table's primary key
  8. $primaryKey = 'id';
  9. // Array of database columns which should be read and sent back to DataTables.
  10. // The `db` parameter represents the column name in the database, while the `dt`
  11. // parameter represents the DataTables column identifier. In this case object
  12. // parameter names
  13. $columns = array(
  14. array( 'db' => 'first_name', 'dt' => 'first_name' ),
  15. array( 'db' => 'last_name', 'dt' => 'last_name' ),
  16. array( 'db' => 'position', 'dt' => 'position' ),
  17. array( 'db' => 'office', 'dt' => 'office' ),
  18. array(
  19. 'db' => 'start_date',
  20. 'dt' => 'start_date',
  21. 'formatter' => function( $d, $row ) {
  22. return date( 'jS M y', strtotime($d));
  23. }
  24. ),
  25. array(
  26. 'db' => 'salary',
  27. 'dt' => 'salary',
  28. 'formatter' => function( $d, $row ) {
  29. return '$'.number_format($d);
  30. }
  31. )
  32. );
  33. // SQL server connection information
  34. $sql_details = array(
  35. 'user' => '',
  36. 'pass' => '',
  37. 'db' => '',
  38. 'host' => ''
  39. );
  40. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  41. * If you just want to use the basic configuration for DataTables with PHP
  42. * server-side, there is no need to edit below this line.
  43. */
  44. require( 'ssp.class.php' );
  45. echo json_encode(
  46. SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )
  47. );