kirimemail/phalcon-datatables
Composer 安装命令:
composer require kirimemail/phalcon-datatables
包简介
A DataTables adapter for Phalcon Framework
关键字:
README 文档
README
About
This is a Phalcon Framework adapter for DataTables.
Support
Currently supported
- QueryBuilder interface
- ResultSet interface
- Pagination
- Raw query interface(*new)
- Global search (by value)
- Ordering
- Multiple column ordering
- Column-based search
- Caching
Installation
Installation via Composer
- Install a composer
- Create
composer.jsonfile inside your project directory - Paste into it
{
"require": {
"kirimemail/phalcon-datatables": "1.*"
}
}
- Run
composer update
Example usage
It uses Phalcon QueryBuilder for pagination in DataTables.
In example we have a standart MVC application, with database enabled. Don't need to provide a normal bootstrap PHP file, for Phalcon documentation, visit official site.
Controller (using QueryBuilder):
<?php use \DataTables\DataTable; class TestController extends \Phalcon\Mvc\Controller { public function indexAction() { if ($this->request->isAjax()) { $builder = $this->modelsManager->createBuilder() ->columns('id, name, email, balance') ->from('Example\Models\User'); $dataTables = new DataTable(); $dataTables->fromBuilder($builder)->sendResponse(); } } }
Controller (using ResultSet):
<?php use \DataTables\DataTable; class TestController extends \Phalcon\Mvc\Controller { public function indexAction() { if ($this->request->isAjax()) { $resultset = $this->modelsManager->createQuery("SELECT * FROM \Example\Models\User") ->execute(); $dataTables = new DataTable(); $dataTables->fromResultSet($resultset)->sendResponse(); } } }
Controller (using Array):
<?php use \DataTables\DataTable; class TestController extends \Phalcon\Mvc\Controller { public function indexAction() { if ($this->request->isAjax()) { $array = $this->modelsManager->createQuery("SELECT * FROM \Example\Models\User") ->execute()->toArray(); $dataTables = new DataTable(); $dataTables->fromArray($array)->sendResponse(); } } }
Controller (using Raw Query):
<?php use \DataTables\DataTable; class TestController extends \Phalcon\Mvc\Controller { public function indexAction() { if ($this->request->isAjax()) { $dataTables = new DataTable(); $dataTables->fromQuery([ "select"=> "*", "from"=> "user" ])->sendResponse(); } } }
Model:
<?php /** * @property integer id * @property string name * @property string email * @property float balance */ class User extends \Phalcon\Mvc\Model { }
View:
<html> <head> <title>Simple DataTables Application</title> <script type="text/javascript" language="javascript" src="//code.jquery.com/jquery-1.11.1.min.js"></script> <script type="text/javascript" language="javascript" src="//cdn.datatables.net/1.10.4/js/jquery.dataTables.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#example').DataTable({ serverSide: true, ajax: { url: '/test/index', method: 'POST' }, columns: [ {data: "id", searchable: false}, {data: "name"}, {data: "email"}, {data: "balance", searchable: false} ] }); }); </script> </head> <body> <table id="example"> <thead> <th>ID</th> <th>Username</th> <th>Email</th> <th>Balance</th> </thead> <tbody> </tbody> </table> </body> </html>
Options
There are few additional option available
<?php $options = [ /** * Cache options, enabled by default, and defined by hash of the query. * Used for caching total and filtered, which is used by in each call. * By caching it, we are decreasing the query need to run. */ "cache_enabled"=>true, "cache_di"=>"modelsCache", "cache_lifetime"=>3600 ]; //example $dt = new \DataTables\DataTable($options); ?>
More examples
For more examples please search in site directory.
It contains basic Phalcon bootstrap page to show all Phalcon-DataTables functionality.
This is fork repo from m10me/phalcon-datatables with some bugfix and additional methods.
kirimemail/phalcon-datatables 适用场景与选型建议
kirimemail/phalcon-datatables 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 623 次下载、GitHub Stars 达 2, 最近一次更新时间为 2017 年 10 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「plugin」 「datatables」 「phalcon」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 kirimemail/phalcon-datatables 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kirimemail/phalcon-datatables 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 kirimemail/phalcon-datatables 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
DataTables is a plug-in for the jQuery Javascript library. It is a highly flexible tool, based upon the foundations of progressive enhancement, which will add advanced interaction controls to any HTML table.
Laravel DataTables plugin to support Mongodb
Plug-ins for DataTables
Vanilla Components Integration with Laravel
Views for the package MedicOneSystems Livewire Datatables with Bootstrap 4
统计信息
- 总下载量: 623
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-10-03