heyday/silverstripe-querybuilder
Composer 安装命令:
composer require heyday/silverstripe-querybuilder
包简介
Builds complex and composable queries to retrieve ArrayLists in SilverStripe
README 文档
README
Provides a way to create queries that are flexible and reusable in SilverStripe. A lot like Search Filters.
Installation (with composer)
Installing from composer is easy,
Create or edit a composer.json file in the root of your SilverStripe project, and make sure the following is present.
{
"require": {
"heyday/silverstripe-querybuilder": "1.2.*"
}
}
After completing this step, navigate in Terminal or similar to the SilverStripe root directory and run composer install or composer update depending on whether or not you have composer already in use.
Overview
Query builder is a wrapper around the SQLQuery object, providing two ways to modify the SQLQuery object:
Heyday\QueryBuilder\Interfaces\QueryModifierInterface- Closure with function signiture
SQLQuery $query, array $data, QueryBuilderInterface $queryBuilder
Usage
Implementing QueryModifierInterface
This is a very general modifier, modifiers you build might be more specific to your model.
use Heyday\QueryBuilder\Interfaces\QueryBuilderInterface; use Heyday\QueryBuilder\Interfaces\QueryModifierInterface; class LikeModifier extends QueryModifierInterface { protected $column; public function __construct($column) { $this->column = $column; } public function modify(\SQLQuery $query, array $data, QueryBuilderInterface $queryBuilder) { if (isset($data['search']) && $data['search']) { $query->addWhere("{$this->column} LIKE '%{$data['search']}%'"); } } }
Using a modifier with QueryBuilder
use Heyday\QueryBuilder\QueryBuilder; $qb = new QueryBuilder( 'SiteTree', [new LikeModifier('SiteTree.Title')], ['search' => $request->getVar('q')] ); foreach ($qb as $page) { // Do something with page }
License
SilverStripe Query Builder is licensed under an MIT license
heyday/silverstripe-querybuilder 适用场景与选型建议
heyday/silverstripe-querybuilder 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.49k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2014 年 09 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 heyday/silverstripe-querybuilder 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 heyday/silverstripe-querybuilder 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.49k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-09-08