riculum/php-datatables
Composer 安装命令:
composer require riculum/php-datatables
包简介
Simple PHP extension for Datatables
README 文档
README
Simple PHP extension for Datatables
Installation
Use the package manager composer to install the library
composer require riculum/php-datatables
Initial setup
Credentials
The basic database settings can be set through environment variables. Add a .env file in the root of your project. Make sure the .env file is added to your .gitignore so it is not checked-in the code. By default, the library looks for the following variables:
- DB_HOST
- DB_NAME
- DB_USERNAME
- DB_PASSWORD
More information how to use environment variables here
Configuration
Import vendor/autoload.php and load the .env settings
require_once 'vendor/autoload.php'; use Database\Core\Database as DB; $dotenv = Dotenv\Dotenv::createImmutable(__DIR__); $dotenv->load();
Datatables
BASIC
To get the properly formatted data, you just need to define the table and columns
$table = "user"; $columns = ["id", "firstname", "lastname", "company", "address", "city", "email", "phone"]; echo Datatable::getDatatable($table, $columns);
JOIN
To combine multiple tables with related columns, use the SQL JOIN statement
$table = "user JOIN city ON user.zip = city.zip"; $columns = ["user.id", "firstname", "lastname", "company", "address", "city.name", "email", "phone"]; echo Datatable::getDatatable($table, $columns);
Notice to specify the columns with table names
WHERE
Use the WHERE clause to extract with priority only those records that meet a certain condition
$table = "user"; $columns = ["id", "firstname", "lastname", "company", "address", "city", "email", "phone"]; $where = [ 'key' => 'id', 'operator' => '=', 'value' => 1 ]; echo Datatable::getDatatable($table, $columns, $where);
Bugreport & Contribution
If you find a bug, please either create a ticket in github, or initiate a pull request
Versioning
We adhere to semantic (major.minor.patch) versioning (https://semver.org/). This means that:
- Patch (x.x.patch) versions fix bugs
- Minor (x.minor.x) versions introduce new, backwards compatible features or improve existing code.
- Major (major.x.x) versions introduce radical changes which are not backwards compatible.
In your automation or procedure you can always safely update patch & minor versions without the risk of your application failing.
riculum/php-datatables 适用场景与选型建议
riculum/php-datatables 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 04 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 riculum/php-datatables 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 riculum/php-datatables 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 8
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-04-15