phputil/datatables
最新稳定版本:2.0.1
Composer 安装命令:
composer require phputil/datatables
包简介
PHP representation of Datatables' request and response.
关键字:
README 文档
README
PHP representation of Datatables' request and response.
Main files:
- Class DataTablesRequest
- Class DataTablesResponse
This project uses semantic versioning. See our releases.
Installation
composer require phputil/datatables
Example on version 2.x
<?php require_once 'vendor/autoload.php'; use phputil\datatables\DataTablesRequest; use phputil\datatables\DataTablesResponse; // // REQUEST // $req = new DataTablesRequest( $_POST ); // PAGINATION $offset = $req->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 require_once 'vendor/autoload.php'; use phputil\DataTablesRequest; use phputil\DataTablesResponse; // // REQUEST // $req = new DataTablesRequest( $_POST ); // PAGINATION $limit = $req->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 ); ?>
统计信息
- 总下载量: 618
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 1
其他信息
- 授权协议: LGPL-3
- 更新时间: 2016-04-22