Subversion-Projekte lars-tiefland.ci

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
875 lars 1
<?php
2
 
3
/*
4
 * DataTables example server-side processing script.
5
 *
6
 * Please note that this script is intentionally extremely simply to show how
7
 * server-side processing can be implemented, and probably shouldn't be used as
8
 * the basis for a large complex system. It is suitable for simple use cases as
9
 * for learning.
10
 *
11
 * See http://datatables.net/usage/server-side for full details on the server-
12
 * side processing requirements of DataTables.
13
 *
14
 * @license MIT - http://datatables.net/license_mit
15
 */
16
 
17
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
18
 * Easy set variables
19
 */
20
 
21
// DB table to use
22
$table = 'datatables_demo';
23
 
24
// Table's primary key
25
$primaryKey = 'id';
26
 
27
// Array of database columns which should be read and sent back to DataTables.
28
// The `db` parameter represents the column name in the database, while the `dt`
29
// parameter represents the DataTables column identifier - in this case object
30
// parameter names
31
$columns = array(
32
	array(
33
		'db' => 'id',
34
		'dt' => 'DT_RowId',
35
		'formatter' => function( $d, $row ) {
36
			// Technically a DOM id cannot start with an integer, so we prefix
37
			// a string. This can also be useful if you have multiple tables
38
			// to ensure that the id is unique with a different prefix
39
			return 'row_'.$d;
40
		}
41
	),
42
	array( 'db' => 'first_name', 'dt' => 'first_name' ),
43
	array( 'db' => 'last_name',  'dt' => 'last_name' ),
44
	array( 'db' => 'position',   'dt' => 'position' ),
45
	array( 'db' => 'office',     'dt' => 'office' ),
46
	array(
47
		'db'        => 'start_date',
48
		'dt'        => 'start_date',
49
		'formatter' => function( $d, $row ) {
50
			return date( 'jS M y', strtotime($d));
51
		}
52
	),
53
	array(
54
		'db'        => 'salary',
55
		'dt'        => 'salary',
56
		'formatter' => function( $d, $row ) {
57
			return '$'.number_format($d);
58
		}
59
	)
60
);
61
 
62
$sql_details = array(
63
	'user' => '',
64
	'pass' => '',
65
	'db'   => '',
66
	'host' => ''
67
);
68
 
69
 
70
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
71
 * If you just want to use the basic configuration for DataTables with PHP
72
 * server-side, there is no need to edit below this line.
73
 */
74
 
75
require( 'ssp.class.php' );
76
 
77
echo json_encode(
78
	SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )
79
);
80