Managed Tables
Standard Entries Collections store flexible JSON payloads plus an inverted search index. When a feature needs high-volume transactional SQL storage (such as email subscriptions, booking holds, inventory buckets, sequences, or immutable ledgers), use Managed Tables ($wire->entries->tables()).
Physical SQL table names normalize automatically to the entries_tbl_ prefix (entries_tbl_<name>), keeping them isolated from ProcessWire core tables. Writable tables also receive zero-code admin CRUD screens (./table-edit/) inside Setup -> Entries.
Declaring a Managed Table
Section titled “Declaring a Managed Table”-
Scaffold a table blueprint
Terminal window php vendor/bin/wire make:entry booking_holds --kind=table -
Define columns, options, and indexes in
site/entries/tables/booking_holds.yaml:site/entries/tables/booking_holds.yaml title: Booking Holdstable: booking_holdsowner: siteidStrategy: uuid7 # 'uuid7' | 'bigint' | 'string'timestamps:- created_at- updated_atsoftDeletes: true # Adds nullable deleted_at + idx_deleted_at (incompatible with appendOnly)userstamps:- created_by- updated_byexportPolicy: data # 'schema_only' | 'data' | 'skip'defaultSort: -created_atlistColumns:- reference_code- status- amount_minor- expires_atcolumns:reference_code:type: stringlength: 64searchable: truefilterable: truelabel: Referencetitle:type: stringlength: 191useLanguages: true # Stored in companion entries_tbl_booking_holds_i18nsearchable: truelabel: Titlestatus:type: stringlength: 32default: activefilterable: truelabel: Statusamount_minor:type: bigintdefault: 0label: Amount (Minor Units)expires_at:type: datetimenullable: truelabel: Expires Atunique:uq_reference_code:- reference_codeindexes:idx_status_expires:- status- expires_at -
Preview and apply additive DDL sync (MySQL, SQLite, and PostgreSQL compatible):
Terminal window php vendor/bin/wire entries:tables:sync --dry-run --jsonphp vendor/bin/wire entries:tables:sync --json
Supported column types (TableColumn::SUPPORTED_TYPES)
Section titled “Supported column types (TableColumn::SUPPORTED_TYPES)”- Strings & JSON:
uuid,char,string,text,mediumtext,longtext,json - Numbers & booleans:
bool,tinyint,utinyint,smallint,usmallint,int,uint,bigint,ubigint,decimal - Dates:
date,datetime - Translatable (
useLanguages: true):char,string,text,mediumtext,longtext(stored inentries_tbl_<name>_i18n, created only when at least one column is translatable)
Blueprint options also include appendOnly: true (immutable audit/ledger rows) and userstamps (user_id, created_by, updated_by, deleted_by).
Querying with ProcessWire selectors and fluent TableQuery
Section titled “Querying with ProcessWire selectors and fluent TableQuery”$entries->tables() compiles ProcessWire selectors safely against your blueprint’s column allowlist (failing closed on unknown columns or hidden/sensitive columns when allowHidden: false):
<?php
declare(strict_types=1);
namespace ProcessWire;
$tables = $this->wire()->entries->tables();
// 1. ProcessWire selector queries (find, findOne, findPaginated, findMany, count)$rows = $tables->find('booking_holds', 'status=active|pending, amount_minor>=1000, sort=-created_at, limit=25');$one = $tables->findOne('booking_holds', 'reference_code^=HLD-2026', ['select' => ['id', 'reference_code', 'status']]);$page = $tables->findPaginated('booking_holds', '(status=active, amount_minor>=5000), (status=priority)', page: 1, limit: 20);$count = $tables->count('booking_holds', 'status!=cancelled, include=all');
// 2. Free-text search across searchable columns$hits = $tables->search('booking_holds', 'aegean charter', [ 'mode' => 'all_words', // 'contains' | 'all_words' | 'prefix' 'selector' => 'status=active', 'limit' => 25,]);
// 3. Fluent TableQuery with _i18n locale, keyset cursor, and row lock$locked = $tables->query('booking_holds') ->lang('tr') ->withTranslations() ->whereSelector('status=active, amount_minor>0') ->forUpdate() ->get();Writes, upserts, atomic counters, sequences, and SKIP LOCKED
Section titled “Writes, upserts, atomic counters, sequences, and SKIP LOCKED”<?php
declare(strict_types=1);
namespace ProcessWire;
$tables = $this->wire()->entries->tables();
// Insert, batch insert, and dialect-safe upsert$id = $tables->insert('booking_holds', [ 'reference_code' => 'HLD-2026-001', 'status' => 'active', 'amount_minor' => 250000,]);
$tables->upsert('daily_metrics', ['metric_date' => '2026-07-01', 'views' => 1], incrementColumns: ['views']);
// Atomic transaction with FOR UPDATE row lock$tables->transaction(function () use ($tables, $id): void { $row = $tables->findById('booking_holds', $id, forUpdate: true); if ($row !== null && $row['status'] === 'active') { $tables->updateById('booking_holds', $id, ['status' => 'confirmed']); }});
// Atomic counter adjustment with guard conditions, monotonic sequences, and SKIP LOCKED job claiming$tables->atomicAdjust('inventory_buckets', ['sku' => 'CABIN-A'], ['available' => -1, 'reserved' => 1], ['available' => ['>=', 1]]);$nextNo = $tables->nextSequence('invoice_sequences', 'INV-2026');$claimed = $tables->claimBatch('dispatch_queue', ['status' => 'queued'], ['status' => 'processing'], limit: 50);
// Soft-delete lifecycle (when softDeletes: true)$tables->deleteById('booking_holds', $id);$tables->restoreById('booking_holds', $id);$tables->forceDeleteById('booking_holds', $id);Zero-code Admin CRUD and lifecycle hooks
Section titled “Zero-code Admin CRUD and lifecycle hooks”- Every registered table appears automatically under Setup -> Entries -> Managed Tables (
TableDataProviderwith'entries-table:<handle>'andTableRecordEditor). - Hook
TableService::inserted,TableService::updated,TableService::deleted, andTableService::restoredto react to mutations (sensitivecolumns are redacted automatically).