emagombe/datatable
Composer 安装命令:
composer require emagombe/datatable
包简介
PHP Server-side processing datatable
README 文档
README
This lib allows to process DataTable data content from server-side using PHP
Instalation
Using composer
composer require emagombe/datatable
Without composer
Clone the project or download a release from https://github.com/emagombe/datatable/releases And import autoload.php file to you project
require_once 'autoload.php';
Generating server-side data
from PDOStatement object
In the static method create pass the PDOStatement object then call the build object method to execute and return the output
use emagombe\DataTable; $sql = "SELECT * FROM table;"; $stmt = $conn->prepare($sql); $dt = DataTable::create($stmt)->build(); echo $dt;
from Array
Same as above, pass a array to the static method create then call the build object method to execute and return the output
use emagombe\DataTable; $array = []; $dt = DataTable::create($array)->build(); echo $dt;
Streaming response
Use the stream method to print the response
DataTable::create($result)->stream();
Adding custom column
Call the object method addColumn to add a custom column. This method receives the current row as parameter;
Note: The callback should return a string containing the custom content of the column!
$dt = DataTable::create($result)->addColumn("action", function($row) { return "<b>".$row["name"]."</b>"; })->build();
addColumn params
| order | data type |
|---|---|
| first | string |
| second | method |
统计信息
- 总下载量: 74
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-08-13