timmit / db-filter
A simple DB filter layer in PHP
v1.0.1
2026-11-27 11:26 UTC
Requires
- php: >=8.0
- timmit/db-mysql: >=v11.0
Requires (Dev)
- phpstan/phpstan: ^1.4.8
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-strict-rules: ^1.1
- phpunit/phpunit: 10.5.62
- timmit/php-docblock-checker: ^1.11
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-27 12:00:44 UTC
README
Parses a compact filter expression into a TiMMiT\MySQL\Where\Collection for one column.
Install
composer require timmit/db-filter
Requires PHP >= 8.0 and timmit/db-mysql >= v11.0. The return value is a where-collection from that package.
Usage
use TiMMiT\DBFilter\Engine; $engine = new Engine(); $where = $engine->parse('!(abc|def)&~x', 'name', 'items');
parse() takes the expression, the column name, and an optional table name.
| Syntax | Meaning |
|---|---|
token |
Exact match |
~text |
Contains |
prefix* |
Prefix match |
a-b |
Range |
/pattern/ |
Regular expression |
& |
And |
| or , |
Or |
! |
Not |
(...) |
Grouping |
!(abc|def)&~x is "not (abc or def), and contains x".
License
MIT.