expedition/wpqb
Composer 安装命令:
composer require expedition/wpqb
包简介
Build queries with an elegant WordPress-oriented query builder
README 文档
README
A flexible and powerful query builder tailored for WordPress, making complex database queries simple.
Description
WP Query Builder is a modern and extensible PHP library that offers a fluent, chainable interface to build and execute WordPress database queries. Instead of writing raw SQL or wrestling with WP's default methods, use this query builder to easily compose advanced queries.
If you like WPQB, please consider starring it.
Features
- Fluent, chainable API for easy query composition.
- Support for various query types: SELECT, UPDATE, INSERT, and more. (under development)
- Built-in safeguards and helpers to avoid SQL injection.
- Supports advanced query features like joins, ordering, and limits.
- Integrated with the global $wpdb WordPress database object for query preparation and execution.
- 80%+ code coverage, so you can be sure the plugin works reliably.
- Perfect static analysis results.
Installation
Simply download the latest release and put it in your plugins folder, or use the plugin installer in WordPress. You're ready to start writing kick-ass queries!
Basic usage
use Expedition\Wpqb\Query;
// Select query
$results = Query::select('name')
->distinct()
->from('wp_posts')
->where('post_status', '=', 'publish')
->where('post_type', '=', 'post')
->limit(10)
->orderBy('post_date', 'DESC')
->get();
Why WPQB instead of other plugins?
There are other PHP packages out there that help you with query building such as doctrine/dbal. It's a brilliant package, it truly is. For WordPress, there are a few cons however:
- Because they don't deeply integrate with WordPress, they won't trigger all hooks, filters and caching mechanisms.
- You miss out on optimisations that have been done for
$wpdb. - A lot of extra overhead has to be imported, especially if it's an entire ORM.
These drawbacks are tackled by using this plugin.
Contribution
Help is greatly appreciated here! There's a lot that still needs to be done, as it is currently just a weekend project. You can contribute in a lot of different ways:
- Writing tests
- Writing documentation (or examples for users of the plugin)
- Writing code
- Opening issues
- Tell others!
Tools
- PHPStan: Run PHPStan with
composer run-script phpstan - PHP RC Fixer: Run the PHP RC Fixer with
composer run-script phprcfix - PEST: Run PEST with
composer run-script test
License
This plugin is licensed under the MIT-license. Do whatever you like with it. Go conquer the world. Or don't.
expedition/wpqb 适用场景与选型建议
expedition/wpqb 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 13, 最近一次更新时间为 2023 年 12 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 expedition/wpqb 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 expedition/wpqb 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 13
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-12-01