Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thiagodp/datatables
PHP representation of (jQuery) Datatables's request and response.
https://github.com/thiagodp/datatables
datatables jquery php phputil request response wrapper
Last synced: 1 day ago
JSON representation
PHP representation of (jQuery) Datatables's request and response.
- Host: GitHub
- URL: https://github.com/thiagodp/datatables
- Owner: thiagodp
- License: lgpl-3.0
- Created: 2016-04-22T09:55:04.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-12T23:57:28.000Z (over 6 years ago)
- Last Synced: 2024-09-26T07:54:49.484Z (about 1 month ago)
- Topics: datatables, jquery, php, phputil, request, response, wrapper
- Language: PHP
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Datatables
PHP representation of [Datatables](https://datatables.net)' request and response.
Main files:
* Class [DataTablesRequest](https://github.com/thiagodp/datatables/blob/master/lib/DataTablesRequest.php)
* Class [DataTablesResponse](https://github.com/thiagodp/datatables/blob/master/lib/DataTablesResponse.php)This project uses [semantic versioning](http://semver.org/). See our [releases](https://github.com/thiagodp/datatables/releases).
### Installation
```command
composer require phputil/datatables
```### Example on version `2.x`
```php
start;
$limit = $req->length;// SEARCH
$searchValue = $req->searchValue(); // Example: 'Alice'// FILTERING
$search = $req->columnSearch(); // Example: array( 'name' => 'Bob', 'age' => 21 )// SORTING
$order = $req->columnOrder(); // Example: array( 'name' => 'ASC', 'age' => 'DESC' )...
//
// RESPONSE
//
$totalCount = /* total number of records to return */
$filteredCount = /* filtered number of records to return */
$data = /* items to return */
$draw = $req->draw; // From the request$res = new DataTablesResponse(
$totalCount, $filteredCount, $data, $draw );
echo json_encode( $res );
?>
```### Example on version `1.x`
```php
limit();
$offset = $req->offset();// SEARCH
$search = $req->search(); // null in case of not having search// FILTERING
$filters = $req->filters(); // Example: array( 'name' => 'Bob', 'age' => 21 )// SORTING
// Originally, Datatables returns the sort order
// by column index, but here you can get it using
// your own column names.
$orders = $req->orders( array( 'name', 'age' ) ); // Example: array( 'name' => 'asc', 'age' => 'desc' )...
//
// RESPONSE
//
$totalCount = /* total number of records to return */
$filteredCount = /* filtered number of records to return */
$data = /* items to return */
$draw = $req->draw(); // From the request$res = new DataTablesResponse(
$totalCount, $filteredCount, $data, $draw );
echo json_encode( $res );
?>
```