mini\Util\QueryParser class

Documentation

QueryParser - Parse and match query string criteria

Supports clean colon syntax for operators:

Operators: eq, gt, gte, lt, lte, like

Syntax examples:

  • key=value (simple equality)
  • key:eq=value (explicit equality)
  • key:gt=10 (greater than)
  • key:gte=18 (greater than or equal)
  • key:lt=100 (less than)
  • key:lte=50 (less than or equal)
  • key:like=pattern (contains pattern)
  • key:like=pattern* (starts with pattern)
  • key:like=*pattern (ends with pattern)
  • age:gte=18&age:lte=65 (range query)

Usage: $qp = new QueryParser($_GET); $qp = new QueryParser("id=5&age:gte=18&score:gt=80"); $qp = new QueryParser($_GET, ["id", "name", "age"]); // with whitelist

foreach ($rows as $row) { if ($qp->matches($row)) { // row matches criteria } }

Properties (3)

private array $query
private array $allowedOperators
private array $operatorMap

Methods (9)

Documentation missing

Check if an object or array matches the query criteria

Get the parsed query array (for debugging)

Get the normalized query structure

Parse query string using PHP's built-in parse_str with colon syntax support

Process colon syntax in parsed query parameters

Parse the input into a normalized query structure

Compare two values using SQLite3 semantics

Check if a string matches a LIKE pattern with * wildcards

Source

src/Util/QueryParser.php:35-271