Tiger_Model_Table
@api· extendsZend_Db_Table_Abstract
Base table-gateway for Tiger models.
Extends ZF1's Zend_Db_Table_Abstract (Table Data Gateway) and maintains the standard boilerplate every Tiger domain table carries — automatically, and only when the column actually exists (so the base is safe for tables that omit some):
- UUID primary keys, generated in PHP on insert (v7 by default — see Tiger_Uuid for why; set $_uuidVersion = 4 for opaque-timing tables).
- created_at / updated_at timestamps.
- created_by / updated_by actor stamps — the user_id from the current actor (see setActor()/actor()); NULL when there's no actor (system/genesis/CLI).
- deleted soft-delete flag — softDelete()/restore() flip it, and reads exclude deleted rows by default (findById, activeSelect).
Because the PK is a client-generated UUID (not auto-increment), insert() is overridden to (a) mint the id and (b) return the UUID string — ZF1's default returns lastInsertId(), meaningless for a string PK.
CONVENTION: Tiger domain tables carry status, deleted, created_by, updated_by, created_at, updated_at. Audit TRAILS (change history) are an app concern, not core's — an app adds audit tables if it needs them.
Subclasses declare $_name and $_primary and (optionally) domain helper methods that build on activeSelect() so soft-deleted rows stay hidden. Metadata is lazy-loaded on first use, so this class is cheap to load without a DB.
Methods
setActor()
setActor($userId)
Set the current actor (a user_id). Auth calls this on login.
$userIdstring|null— the acting user's id, or null for system/CLI
actor()
actor()
The current actor's user_id, or null in a system/CLI context.
Returns string|null — the acting user's id, or null
insert()
insert(array $data)
Insert a row: mint the UUID PK, stamp created_at/updated_at and (if an actor is set) created_by/updated_by. Any of these you pass explicitly wins.
$dataarray— column => value (omit the PK — we generate it)
Returns string — the generated UUID primary key
update()
update(array $data, $where)
Update rows: refresh updated_at and (if an actor is set) updated_by.
$dataarray$wherearray|string
Returns int — affected rows
softDelete()
softDelete($where)
Soft-delete: flip deleted to 1 (refreshing updated_at/updated_by) instead of removing the row. Falls back to a hard delete if the table has no deleted column, so the call still means "gone." Use delete() for a deliberate hard delete.
$wherearray|string
Returns int — affected rows
restore()
restore($where)
Reverse a soft delete: set deleted back to 0.
$wherearray|string
Returns int — affected rows
findById()
findById($id, $includeDeleted = false)
Fetch a single row by primary key, or null. Respects soft-delete: a deleted row returns null unless $includeDeleted is true.
$idstring$includeDeletedbool
Returns Zend_Db_Table_Row_Abstract|null
activeSelect()
activeSelect()
A select() pre-scoped to non-deleted rows (when the table has deleted). Domain finders should build on THIS, not select(), so soft-deleted rows stay hidden by default.
Returns Zend_Db_Table_Select