Search by

timmit / db-filter

timmit

A simple DB filter layer in PHP

Package info

github.com/timmit-nl/db-filter

Homepage

pkg:composer/timmit/db-filter

Statistics

Installs: 2 730

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.1 2026-11-27 11:26 UTC

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.