Skip to content

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.

  1. Scaffold a table blueprint

    Terminal window
    php vendor/bin/wire make:entry booking_holds --kind=table
  2. Define columns, options, and indexes in site/entries/tables/booking_holds.yaml:

    site/entries/tables/booking_holds.yaml
    title: Booking Holds
    table: booking_holds
    owner: site
    idStrategy: uuid7 # 'uuid7' | 'bigint' | 'string'
    timestamps:
    - created_at
    - updated_at
    softDeletes: true # Adds nullable deleted_at + idx_deleted_at (incompatible with appendOnly)
    userstamps:
    - created_by
    - updated_by
    exportPolicy: data # 'schema_only' | 'data' | 'skip'
    defaultSort: -created_at
    listColumns:
    - reference_code
    - status
    - amount_minor
    - expires_at
    columns:
    reference_code:
    type: string
    length: 64
    searchable: true
    filterable: true
    label: Reference
    title:
    type: string
    length: 191
    useLanguages: true # Stored in companion entries_tbl_booking_holds_i18n
    searchable: true
    label: Title
    status:
    type: string
    length: 32
    default: active
    filterable: true
    label: Status
    amount_minor:
    type: bigint
    default: 0
    label: Amount (Minor Units)
    expires_at:
    type: datetime
    nullable: true
    label: Expires At
    unique:
    uq_reference_code:
    - reference_code
    indexes:
    idx_status_expires:
    - status
    - expires_at
  3. Preview and apply additive DDL sync (MySQL, SQLite, and PostgreSQL compatible):

    Terminal window
    php vendor/bin/wire entries:tables:sync --dry-run --json
    php 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 in entries_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);
  • Every registered table appears automatically under Setup -> Entries -> Managed Tables (TableDataProvider with 'entries-table:<handle>' and TableRecordEditor).
  • Hook TableService::inserted, TableService::updated, TableService::deleted, and TableService::restored to react to mutations (sensitive columns are redacted automatically).
Zero-code Admin CRUD for Booking Holds (entries_tbl_booking_holds) under Setup -> Entries -> Managed Tables.

Next steps