← Persistence

PERSISTENCE FEATURE

Filtering

Mark a property #[Filterable] and the ORM handles the rest — no manual WHERE clauses.

Feature Guide

A quick orientation block that answers the essential questions: what this feature does, how it works, why it matters, and the key concepts behind it.

What this does

Mark a property #[Filterable] and the ORM handles the rest — no manual WHERE clauses.

Filter Criteria

Live filtered result set

No filters applied — showing the broad demo dataset.

10 Matched products
0 Active filters
Name Price Status
Air Purifier $149.99 active
Domain-Driven Design $54.99 active
Ergonomic Chair $299.99 active
Foam Roller $29.99 active
Head First Design Patterns $49.99 active
Linen Shirt $54.99 active
#[Filterable] FilterableTrait FilterableResourceInterface getFilterCriteria()

Verified against Semitexa Ultimate 2026.09.19.1020

Filtering

The #[Filterable] attribute on a ResourceModel property registers that column as a valid filter target. The ORM builds the WHERE clause automatically from the declared filter criteria.

How it works

A resource implements FilterableResourceInterface and uses FilterableTrait. Marking a property #[Filterable] makes that column available to getFilterCriteria(). Repositories pass the criteria to the query builder, which compiles the WHERE clause without manual string construction. Handlers simply pass payload values through to the repository.

Why this matters

Manual WHERE clause construction per property is repetitive and error-prone. A single attribute declaration keeps filter capability co-located with the column definition, and the ORM ensures that only declared filterable columns can appear in generated queries.

© Brian Kernighan: "Controlling complexity is the essence of computer programming."

Model (Filterable) Implementation slice
<?phpdeclare(strict_types=1);namespace App\Application\Db\Model;use Semitexa\Orm\Attributes\Column;use Semitexa\Orm\Attributes\FromTable;#[FromTable(name: 'products')]final class ProductResource{    #[Column(type: 'uuid')]    public string $id;    #[Column(type: 'varchar', length: 255)]    public string $name;    #[Column(type: 'decimal', precision: 10, scale: 2)]    public string $price;    #[Column(type: 'varchar', length: 32)]    public string $status;}

Support Semitexa
Built for developers who prefer control over magic. Your support helps keep it fast, open, and evolving.

Donate via PayPal