定制 phputil/datatables 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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:

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL-3
  • 更新时间: 2016-04-22