Record
extends AbstractRecord
in package
Record class
Tags
Table of Contents
Properties
- $currentWithIndex : int
- Current with index
- $fillable : array<string|int, mixed>
- Fillable columns (mass-assignment allowlist) - if non-empty, only these columns are settable via fill(); $guarded is ignored when this is non-empty
- $guarded : array<string|int, mixed>
- Guarded columns (mass-assignment denylist) - ignored if $fillable is non-empty
- $isNew : bool
- Is new record flag
- $isTransaction : bool
- Is transaction flag
- $latest : bool
- Relationship latest flag
- $oldest : bool
- Relationship oldest flag
- $prefix : string|null
- Table prefix
- $primaryKeys : array<string|int, mixed>
- Primary keys
- $relationships : array<string|int, mixed>
- Relationships
- $relationshipSortBy : string
- Relationship sort-by field
- $rowGateway : Row|null
- Row gateway
- $table : string|null
- Table name
- $tableGateway : Table|null
- Table gateway
- $with : array<string|int, mixed>
- With relationships
- $withChildren : array<string|int, mixed>
- With relationship children (each entry is an array of dotted child paths for that relationship)
- $withOptions : array<string|int, mixed>
- With relationship options
Methods
- __callStatic() : Collection|array<string|int, mixed>|null
- Call static method for 'findWhere'
- __construct() : mixed
- Constructor
- __get() : mixed
- Magic method to return the value of $this->rowGateway[$name]
- __isset() : bool
- Magic method to return the isset value of $this->rowGateway[$name]
- __set() : void
- Magic method to set the property to the value of $this->rowGateway[$name]
- __unset() : void
- Magic method to unset $this->rowGateway[$name]
- addWith() : AbstractRecord
- Set with relationships
- belongsTo() : Record|BelongsTo
- Belongs to relationship
- commit() : void
- Commit transaction with the DB adapter
- commitTransaction() : AbstractRecord
- Commit transaction
- copy() : static
- Copy the record (alias to replicate)
- count() : int
- Method to get count of fields in row gateway
- countRows() : int
- Get the count of rows returned in the result
- db() : AbstractAdapter
- Get DB adapter (alias)
- decrement() : void
- Decrement the record column and save
- delete() : void
- Delete the record
- execute() : Collection|array<string|int, mixed>|int
- Static method to execute a custom prepared SQL statement.
- fill() : AbstractRecord
- Mass-assign columns, filtered through $fillable/$guarded via isFillable()
- findAll() : Collection|array<string|int, mixed>|static
- Find all static method
- findBy() : Collection|array<string|int, mixed>
- Find by static method
- findById() : static|array<string|int, mixed>
- Find by ID static method
- findByOrCreate() : static|Collection|array<string|int, mixed>
- Find by or create static method
- findIn() : array<string|int, mixed>
- Find in static method
- findLatest() : static|array<string|int, mixed>
- Find latest static method
- findOne() : static|array<string|int, mixed>
- Find one static method
- findOneOrCreate() : static|array<string|int, mixed>
- Find one or create static method
- findWhereBetween() : static
- findWhereEquals() : static
- findWhereGreaterThan() : static
- findWhereGreaterThanOrEqual() : static
- findWhereIn() : static
- findWhereLessThan() : static
- findWhereLessThanOrEqual() : static
- findWhereLike() : static
- findWhereNotBetween() : static
- findWhereNotEquals() : static
- findWhereNotIn() : static
- findWhereNotLike() : static
- findWhereNotNull() : static
- findWhereNull() : static
- getAll() : Collection|array<string|int, mixed>
- Get all method
- getBy() : Collection|array<string|int, mixed>
- Get by method
- getById() : static|array<string|int, mixed>
- Get by ID method
- getDb() : AbstractAdapter
- Get DB adapter
- getDirty() : array<string|int, mixed>
- Get row's dirty columns
- getFullTable() : string
- Get the full table name (prefix + table)
- getIn() : array<string|int, mixed>
- Get in method
- getIterator() : ArrayIterator
- Method to iterate over the columns
- getOne() : static|array<string|int, mixed>
- Get one method
- getPrefix() : string|null
- Get the table prefix
- getPrimaryKeys() : array<string|int, mixed>
- Get the primary keys
- getPrimaryValues() : array<string|int, mixed>
- Get the primary values
- getRelationship() : mixed
- Get relationship
- getRelationships() : array<string|int, mixed>
- Get relationships
- getRowGateway() : Row|null
- Get the row gateway
- getRows() : Collection
- Get the rows
- getSql() : Sql
- Get SQL builder
- getTable() : string|null
- Get the table
- getTableGateway() : Table|null
- Get the table gateway
- getTableInfo() : array<string|int, mixed>
- Static method to get the total count of a set from the DB table
- getTotal() : int
- Static method to get the total count of a set from the DB table
- getWithRelationships() : AbstractRecord
- Get with relationships
- getWiths() : array<string|int, mixed>
- Get with relationships
- hasDb() : bool
- Check for a DB adapter
- hasMany() : mixed
- Has many relationship
- hasOne() : Record|HasOne
- Has one relationship
- hasOneOf() : Record|HasOneOf
- Has one of relationship
- hasRelationship() : bool
- Has relationship
- hasRelationships() : bool
- Get relationships
- hasRows() : bool
- Determine if the result has rows
- hasWith() : bool
- Determine if there is specific with relationship
- hasWiths() : bool
- Determine if there are with relationships
- increment() : void
- Increment the record column and save
- isDirty() : bool
- Check if row is dirty
- isFillable() : bool
- Determine if a column is mass-assignable via fill()
- isTransaction() : bool
- Is transaction
- latest() : static
- Method to set latest flag for relationships
- offsetExists() : bool
- ArrayAccess offsetExists
- offsetGet() : mixed
- ArrayAccess offsetGet
- offsetSet() : void
- ArrayAccess offsetSet
- offsetUnset() : void
- ArrayAccess offsetUnset
- oldest() : static
- Method to set oldest flag for relationships
- parseColumns() : array<string|int, mixed>
- Parse columns and return expressions and params
- predicate() : PredicateSet
- Get a predicate set
- processRow() : mixed
- Process a table row
- processRows() : array<string|int, mixed>
- Process table rows
- processWithRelationships() : AbstractRecord
- Process with relationships
- query() : Collection|array<string|int, mixed>|int
- Static method to execute a custom SQL query.
- replicate() : static
- Replicate the record
- reset() : void
- Reset/clear the record column and save
- resetDirty() : void
- Reset row's dirty columns
- rollback() : Exception|null
- Rollback transaction with the DB adapter
- rollbackTransaction() : AbstractRecord
- Rollback transaction
- rows() : Collection
- Get the rows (alias method)
- save() : void
- Save or update the record
- setColumns() : AbstractRecord
- Set all the table column values at once
- setDb() : void
- Set DB adapter
- setDefaultDb() : void
- Set DB adapter
- setPrefix() : AbstractRecord
- Set the table prefix
- setPrimaryKeys() : AbstractRecord
- Set the primary keys
- setRelationship() : AbstractRecord
- Set relationship
- setRows() : AbstractRecord
- Set all the table rows at once
- setTable() : AbstractRecord
- Set the table
- setTableFromClassName() : AbstractRecord
- Set the table from a class name
- sql() : Sql
- Get SQL builder (alias)
- start() : static|null
- Start transaction with the DB adapter. When called on a descendent class, construct a new object and use it for transaction management.
- startTransaction() : AbstractRecord
- Start transaction
- table() : string
- Get table name
- toArray() : array<string|int, mixed>
- Get column values as array
- transaction() : void
- Execute complete transaction with the DB adapter
- with() : static
- With a 1:many relationship (eager-loading)
- afterDelete() : void
- Called after a single-record delete
- afterInsert() : void
- Called after a single-record insert
- afterSave() : void
- Called after a single-record save() (both insert and update)
- afterUpdate() : void
- Called after a single-record update
- beforeDelete() : void
- Called before a single-record delete
- beforeInsert() : void
- Called before a single-record insert (a new record being saved for the first time)
- beforeSave() : void
- Called before a single-record save() (both insert and update)
- beforeUpdate() : void
- Called before a single-record update (an existing record being saved again)
- buildBetweenConditionColumns() : array<string|int, mixed>
- Build the structured shorthand columns tuple for a findWhereBetween()/findWhereNotBetween() condition
- buildWhereConditionColumns() : array<string|int, mixed>|null
- Build the structured shorthand columns tuple for a findWhere*() condition
- newUnfilteredRecord() : static
- Create a new record instance from trusted, internally-sourced column data
- parseBetweenValues() : array<string|int, mixed>|null
- Normalize a findWhereBetween()/findWhereNotBetween() value into its two boundary values
- parseFindWhereArguments() : array<string|int, mixed>
- Parse the (column, value, options, toArray) arguments for a findWhere*() call
- toColumnsArray() : array<string|int, mixed>
- Normalize a columns argument (array, ArrayObject, AbstractRecord, or any ArrayAccess with a toArray() method) into a plain array
Properties
$currentWithIndex
Current with index
protected
int
$currentWithIndex
= 0
$fillable
Fillable columns (mass-assignment allowlist) - if non-empty, only these columns are settable via fill(); $guarded is ignored when this is non-empty
protected
array<string|int, mixed>
$fillable
= []
$guarded
Guarded columns (mass-assignment denylist) - ignored if $fillable is non-empty
protected
array<string|int, mixed>
$guarded
= []
$isNew
Is new record flag
protected
bool
$isNew
= false
$isTransaction
Is transaction flag
protected
bool
$isTransaction
= false
$latest
Relationship latest flag
protected
bool
$latest
= false
$oldest
Relationship oldest flag
protected
bool
$oldest
= false
$prefix
Table prefix
protected
string|null
$prefix
= null
$primaryKeys
Primary keys
protected
array<string|int, mixed>
$primaryKeys
= ['id']
$relationships
Relationships
protected
array<string|int, mixed>
$relationships
= []
$relationshipSortBy
Relationship sort-by field
protected
string
$relationshipSortBy
= 'id'
$rowGateway
Row gateway
protected
Row|null
$rowGateway
= null
$table
Table name
protected
string|null
$table
= null
$tableGateway
Table gateway
protected
Table|null
$tableGateway
= null
$with
With relationships
protected
array<string|int, mixed>
$with
= []
$withChildren
With relationship children (each entry is an array of dotted child paths for that relationship)
protected
array<string|int, mixed>
$withChildren
= []
$withOptions
With relationship options
protected
array<string|int, mixed>
$withOptions
= []
Methods
__callStatic()
Call static method for 'findWhere'
public
static __callStatic(string $name, array<string|int, mixed> $arguments) : Collection|array<string|int, mixed>|null
$users = Users::findWhereUsername($value);
$users = Users::findWhereEquals($column, $value); $users = Users::findWhereNotEquals($column, $value); $users = Users::findWhereGreaterThan($column, $value); $users = Users::findWhereGreaterThanOrEqual($column, $value); $users = Users::findWhereLessThan($column, $value); $users = Users::findWhereLessThanOrEqual($column, $value);
$users = Users::findWhereLike($column, $value); $users = Users::findWhereNotLike($column, $value);
$users = Users::findWhereIn($column, $values); $users = Users::findWhereNotIn($column, $values);
$users = Users::findWhereBetween($column, $values); $users = Users::findWhereNotBetween($column, $values);
$users = Users::findWhereNull($column); $users = Users::findWhereNotNull($column);
Parameters
- $name : string
- $arguments : array<string|int, mixed>
Return values
Collection|array<string|int, mixed>|null__construct()
Constructor
public
__construct() : mixed
Instantiate the database record object
Optional parameters are an array of column values, db adapter, or a table name
Tags
__get()
Magic method to return the value of $this->rowGateway[$name]
public
__get(string $name) : mixed
Parameters
- $name : string
__isset()
Magic method to return the isset value of $this->rowGateway[$name]
public
__isset(string $name) : bool
Parameters
- $name : string
Return values
bool__set()
Magic method to set the property to the value of $this->rowGateway[$name]
public
__set(string $name, mixed $value) : void
Parameters
- $name : string
- $value : mixed
__unset()
Magic method to unset $this->rowGateway[$name]
public
__unset(string $name) : void
Parameters
- $name : string
addWith()
Set with relationships
public
addWith(string $name[, array<string|int, mixed>|null $options = null ]) : AbstractRecord
Parameters
- $name : string
- $options : array<string|int, mixed>|null = null
Return values
AbstractRecordbelongsTo()
Belongs to relationship
public
belongsTo(string $foreignTable, string|array<string|int, mixed> $foreignKey[, array<string|int, mixed>|null $options = null ][, bool $eager = false ]) : Record|BelongsTo
Parameters
- $foreignTable : string
- $foreignKey : string|array<string|int, mixed>
- $options : array<string|int, mixed>|null = null
- $eager : bool = false
Return values
Record|BelongsTocommit()
Commit transaction with the DB adapter
public
static commit() : void
Tags
commitTransaction()
Commit transaction
public
commitTransaction() : AbstractRecord
Tags
Return values
AbstractRecordcopy()
Copy the record (alias to replicate)
public
copy([array<string|int, mixed> $replace = [] ]) : static
Parameters
- $replace : array<string|int, mixed> = []
Return values
staticcount()
Method to get count of fields in row gateway
public
count() : int
Return values
intcountRows()
Get the count of rows returned in the result
public
countRows() : int
Return values
intdb()
Get DB adapter (alias)
public
static db() : AbstractAdapter
Return values
AbstractAdapterdecrement()
Decrement the record column and save
public
decrement(string $column[, int $amount = 1 ]) : void
Parameters
- $column : string
- $amount : int = 1
delete()
Delete the record
public
delete([array<string|int, mixed>|null $columns = null ][, bool $commit = true ]) : void
Parameters
- $columns : array<string|int, mixed>|null = null
- $commit : bool = true
execute()
Static method to execute a custom prepared SQL statement.
public
static execute(mixed $sql[, array<string|int, mixed> $params = [] ][, bool $toArray = false ]) : Collection|array<string|int, mixed>|int
Parameters
- $sql : mixed
- $params : array<string|int, mixed> = []
- $toArray : bool = false
Return values
Collection|array<string|int, mixed>|intfill()
Mass-assign columns, filtered through $fillable/$guarded via isFillable()
public
fill([mixed $columns = null ]) : AbstractRecord
Parameters
- $columns : mixed = null
Tags
Return values
AbstractRecordfindAll()
Find all static method
public
static findAll([array<string|int, mixed>|null $options = null ][, bool $toArray = false ]) : Collection|array<string|int, mixed>|static
Parameters
- $options : array<string|int, mixed>|null = null
- $toArray : bool = false
Return values
Collection|array<string|int, mixed>|staticfindBy()
Find by static method
public
static findBy([array<string|int, mixed>|PredicateSet|null $columns = null ][, array<string|int, mixed>|null $options = null ][, bool|array<string|int, mixed> $toArray = false ]) : Collection|array<string|int, mixed>
Parameters
- $columns : array<string|int, mixed>|PredicateSet|null = null
- $options : array<string|int, mixed>|null = null
- $toArray : bool|array<string|int, mixed> = false
Return values
Collection|array<string|int, mixed>findById()
Find by ID static method
public
static findById(mixed $id[, array<string|int, mixed>|null $options = null ][, bool $toArray = false ]) : static|array<string|int, mixed>
Parameters
- $id : mixed
- $options : array<string|int, mixed>|null = null
- $toArray : bool = false
Return values
static|array<string|int, mixed>findByOrCreate()
Find by or create static method
public
static findByOrCreate([array<string|int, mixed>|PredicateSet|null $columns = null ][, array<string|int, mixed>|null $options = null ][, bool|array<string|int, mixed> $toArray = false ]) : static|Collection|array<string|int, mixed>
Parameters
- $columns : array<string|int, mixed>|PredicateSet|null = null
- $options : array<string|int, mixed>|null = null
- $toArray : bool|array<string|int, mixed> = false
Return values
static|Collection|array<string|int, mixed>findIn()
Find in static method
public
static findIn(string $key, array<string|int, mixed> $values[, array<string|int, mixed>|PredicateSet|null $columns = null ][, array<string|int, mixed>|null $options = null ][, bool $toArray = false ]) : array<string|int, mixed>
Parameters
- $key : string
- $values : array<string|int, mixed>
- $columns : array<string|int, mixed>|PredicateSet|null = null
- $options : array<string|int, mixed>|null = null
- $toArray : bool = false
Return values
array<string|int, mixed>findLatest()
Find latest static method
public
static findLatest([string|null $by = null ][, array<string|int, mixed>|PredicateSet|null $columns = null ][, array<string|int, mixed>|null $options = null ][, bool $toArray = false ]) : static|array<string|int, mixed>
Parameters
- $by : string|null = null
- $columns : array<string|int, mixed>|PredicateSet|null = null
- $options : array<string|int, mixed>|null = null
- $toArray : bool = false
Return values
static|array<string|int, mixed>findOne()
Find one static method
public
static findOne([array<string|int, mixed>|PredicateSet|null $columns = null ][, array<string|int, mixed>|null $options = null ][, bool $toArray = false ]) : static|array<string|int, mixed>
Parameters
- $columns : array<string|int, mixed>|PredicateSet|null = null
- $options : array<string|int, mixed>|null = null
- $toArray : bool = false
Return values
static|array<string|int, mixed>findOneOrCreate()
Find one or create static method
public
static findOneOrCreate([array<string|int, mixed>|PredicateSet|null $columns = null ][, array<string|int, mixed>|null $options = null ][, bool $toArray = false ]) : static|array<string|int, mixed>
Parameters
- $columns : array<string|int, mixed>|PredicateSet|null = null
- $options : array<string|int, mixed>|null = null
- $toArray : bool = false
Return values
static|array<string|int, mixed>findWhereBetween()
public
findWhereBetween(mixed $column, mixed $values[, array<string|int, mixed> $options = = 'null' ][, bool|array<string|int, mixed> $toArray = = 'false' ]) : static
Parameters
- $column : mixed
- $values : mixed
- $options : array<string|int, mixed> = = 'null'
- $toArray : bool|array<string|int, mixed> = = 'false'
Return values
staticfindWhereEquals()
public
findWhereEquals(mixed $column, mixed $value[, array<string|int, mixed> $options = = 'null' ][, bool|array<string|int, mixed> $toArray = = 'false' ]) : static
Parameters
- $column : mixed
- $value : mixed
- $options : array<string|int, mixed> = = 'null'
- $toArray : bool|array<string|int, mixed> = = 'false'
Return values
staticfindWhereGreaterThan()
public
findWhereGreaterThan(mixed $column, mixed $value[, array<string|int, mixed> $options = = 'null' ][, bool|array<string|int, mixed> $toArray = = 'false' ]) : static
Parameters
- $column : mixed
- $value : mixed
- $options : array<string|int, mixed> = = 'null'
- $toArray : bool|array<string|int, mixed> = = 'false'
Return values
staticfindWhereGreaterThanOrEqual()
public
findWhereGreaterThanOrEqual(mixed $column, mixed $value[, array<string|int, mixed> $options = = 'null' ][, bool|array<string|int, mixed> $toArray = = 'false' ]) : static
Parameters
- $column : mixed
- $value : mixed
- $options : array<string|int, mixed> = = 'null'
- $toArray : bool|array<string|int, mixed> = = 'false'
Return values
staticfindWhereIn()
public
findWhereIn(mixed $column, mixed $values[, array<string|int, mixed> $options = = 'null' ][, bool|array<string|int, mixed> $toArray = = 'false' ]) : static
Parameters
- $column : mixed
- $values : mixed
- $options : array<string|int, mixed> = = 'null'
- $toArray : bool|array<string|int, mixed> = = 'false'
Return values
staticfindWhereLessThan()
public
findWhereLessThan(mixed $column, mixed $value[, array<string|int, mixed> $options = = 'null' ][, bool|array<string|int, mixed> $toArray = = 'false' ]) : static
Parameters
- $column : mixed
- $value : mixed
- $options : array<string|int, mixed> = = 'null'
- $toArray : bool|array<string|int, mixed> = = 'false'
Return values
staticfindWhereLessThanOrEqual()
public
findWhereLessThanOrEqual(mixed $column, mixed $value[, array<string|int, mixed> $options = = 'null' ][, bool|array<string|int, mixed> $toArray = = 'false' ]) : static
Parameters
- $column : mixed
- $value : mixed
- $options : array<string|int, mixed> = = 'null'
- $toArray : bool|array<string|int, mixed> = = 'false'
Return values
staticfindWhereLike()
public
findWhereLike(mixed $column, mixed $value[, array<string|int, mixed> $options = = 'null' ][, bool|array<string|int, mixed> $toArray = = 'false' ]) : static
Parameters
- $column : mixed
- $value : mixed
- $options : array<string|int, mixed> = = 'null'
- $toArray : bool|array<string|int, mixed> = = 'false'
Return values
staticfindWhereNotBetween()
public
findWhereNotBetween(mixed $column, mixed $values[, array<string|int, mixed> $options = = 'null' ][, bool|array<string|int, mixed> $toArray = = 'false' ]) : static
Parameters
- $column : mixed
- $values : mixed
- $options : array<string|int, mixed> = = 'null'
- $toArray : bool|array<string|int, mixed> = = 'false'
Return values
staticfindWhereNotEquals()
public
findWhereNotEquals(mixed $column, mixed $value[, array<string|int, mixed> $options = = 'null' ][, bool|array<string|int, mixed> $toArray = = 'false' ]) : static
Parameters
- $column : mixed
- $value : mixed
- $options : array<string|int, mixed> = = 'null'
- $toArray : bool|array<string|int, mixed> = = 'false'
Return values
staticfindWhereNotIn()
public
findWhereNotIn(mixed $column, mixed $values[, array<string|int, mixed> $options = = 'null' ][, bool|array<string|int, mixed> $toArray = = 'false' ]) : static
Parameters
- $column : mixed
- $values : mixed
- $options : array<string|int, mixed> = = 'null'
- $toArray : bool|array<string|int, mixed> = = 'false'
Return values
staticfindWhereNotLike()
public
findWhereNotLike(mixed $column, mixed $value[, array<string|int, mixed> $options = = 'null' ][, bool|array<string|int, mixed> $toArray = = 'false' ]) : static
Parameters
- $column : mixed
- $value : mixed
- $options : array<string|int, mixed> = = 'null'
- $toArray : bool|array<string|int, mixed> = = 'false'
Return values
staticfindWhereNotNull()
public
findWhereNotNull(mixed $column[, array<string|int, mixed> $options = = 'null' ][, bool|array<string|int, mixed> $toArray = = 'false' ]) : static
Parameters
- $column : mixed
- $options : array<string|int, mixed> = = 'null'
- $toArray : bool|array<string|int, mixed> = = 'false'
Return values
staticfindWhereNull()
public
findWhereNull(mixed $column[, array<string|int, mixed> $options = = 'null' ][, bool|array<string|int, mixed> $toArray = = 'false' ]) : static
Parameters
- $column : mixed
- $options : array<string|int, mixed> = = 'null'
- $toArray : bool|array<string|int, mixed> = = 'false'
Return values
staticgetAll()
Get all method
public
getAll([array<string|int, mixed>|null $options = null ][, bool $toArray = false ]) : Collection|array<string|int, mixed>
Parameters
- $options : array<string|int, mixed>|null = null
- $toArray : bool = false
Return values
Collection|array<string|int, mixed>getBy()
Get by method
public
getBy([array<string|int, mixed>|PredicateSet|null $columns = null ][, array<string|int, mixed>|null $options = null ][, bool $toArray = false ]) : Collection|array<string|int, mixed>
Parameters
- $columns : array<string|int, mixed>|PredicateSet|null = null
- $options : array<string|int, mixed>|null = null
- $toArray : bool = false
Return values
Collection|array<string|int, mixed>getById()
Get by ID method
public
getById(mixed $id[, array<string|int, mixed>|null $options = null ][, bool $toArray = false ]) : static|array<string|int, mixed>
Parameters
- $id : mixed
- $options : array<string|int, mixed>|null = null
- $toArray : bool = false
Return values
static|array<string|int, mixed>getDb()
Get DB adapter
public
static getDb() : AbstractAdapter
Return values
AbstractAdaptergetDirty()
Get row's dirty columns
public
getDirty() : array<string|int, mixed>
Return values
array<string|int, mixed>getFullTable()
Get the full table name (prefix + table)
public
getFullTable() : string
Return values
stringgetIn()
Get in method
public
getIn(string $key, array<string|int, mixed> $values[, array<string|int, mixed>|PredicateSet|null $columns = null ][, array<string|int, mixed>|null $options = null ][, bool $toArray = false ]) : array<string|int, mixed>
Parameters
- $key : string
- $values : array<string|int, mixed>
- $columns : array<string|int, mixed>|PredicateSet|null = null
- $options : array<string|int, mixed>|null = null
- $toArray : bool = false
Return values
array<string|int, mixed>getIterator()
Method to iterate over the columns
public
getIterator() : ArrayIterator
Return values
ArrayIteratorgetOne()
Get one method
public
getOne([array<string|int, mixed>|PredicateSet|null $columns = null ][, array<string|int, mixed>|null $options = null ][, bool $toArray = false ]) : static|array<string|int, mixed>
Parameters
- $columns : array<string|int, mixed>|PredicateSet|null = null
- $options : array<string|int, mixed>|null = null
- $toArray : bool = false
Return values
static|array<string|int, mixed>getPrefix()
Get the table prefix
public
getPrefix() : string|null
Return values
string|nullgetPrimaryKeys()
Get the primary keys
public
getPrimaryKeys() : array<string|int, mixed>
Return values
array<string|int, mixed>getPrimaryValues()
Get the primary values
public
getPrimaryValues() : array<string|int, mixed>
Return values
array<string|int, mixed>getRelationship()
Get relationship
public
getRelationship(string $name) : mixed
Parameters
- $name : string
getRelationships()
Get relationships
public
getRelationships() : array<string|int, mixed>
Return values
array<string|int, mixed>getRowGateway()
Get the row gateway
public
getRowGateway() : Row|null
Return values
Row|nullgetRows()
Get the rows
public
getRows() : Collection
Return values
CollectiongetSql()
Get SQL builder
public
static getSql() : Sql
Return values
SqlgetTable()
Get the table
public
getTable() : string|null
Return values
string|nullgetTableGateway()
Get the table gateway
public
getTableGateway() : Table|null
Return values
Table|nullgetTableInfo()
Static method to get the total count of a set from the DB table
public
static getTableInfo() : array<string|int, mixed>
Return values
array<string|int, mixed>getTotal()
Static method to get the total count of a set from the DB table
public
static getTotal([array<string|int, mixed>|PredicateSet|null $columns = null ][, array<string|int, mixed>|null $options = null ][, mixed $count = 'COUNT(1)' ]) : int
Parameters
- $columns : array<string|int, mixed>|PredicateSet|null = null
- $options : array<string|int, mixed>|null = null
- $count : mixed = 'COUNT(1)'
Return values
intgetWithRelationships()
Get with relationships
public
getWithRelationships([bool $eager = true ]) : AbstractRecord
Parameters
- $eager : bool = true
Return values
AbstractRecordgetWiths()
Get with relationships
public
getWiths() : array<string|int, mixed>
Return values
array<string|int, mixed>hasDb()
Check for a DB adapter
public
static hasDb() : bool
Return values
boolhasMany()
Has many relationship
public
hasMany(string $foreignTable, string|array<string|int, mixed> $foreignKey[, array<string|int, mixed>|null $options = null ][, bool $eager = false ]) : mixed
Parameters
- $foreignTable : string
- $foreignKey : string|array<string|int, mixed>
- $options : array<string|int, mixed>|null = null
- $eager : bool = false
hasOne()
Has one relationship
public
hasOne(string $foreignTable, string|array<string|int, mixed> $foreignKey[, array<string|int, mixed>|null $options = null ][, bool $eager = false ]) : Record|HasOne
Parameters
- $foreignTable : string
- $foreignKey : string|array<string|int, mixed>
- $options : array<string|int, mixed>|null = null
- $eager : bool = false
Return values
Record|HasOnehasOneOf()
Has one of relationship
public
hasOneOf(string $foreignTable, string|array<string|int, mixed> $foreignKey[, array<string|int, mixed>|null $options = null ][, bool $eager = false ]) : Record|HasOneOf
Parameters
- $foreignTable : string
- $foreignKey : string|array<string|int, mixed>
- $options : array<string|int, mixed>|null = null
- $eager : bool = false
Return values
Record|HasOneOfhasRelationship()
Has relationship
public
hasRelationship(string $name) : bool
Parameters
- $name : string
Return values
boolhasRelationships()
Get relationships
public
hasRelationships() : bool
Return values
boolhasRows()
Determine if the result has rows
public
hasRows() : bool
Return values
boolhasWith()
Determine if there is specific with relationship
public
hasWith(string $name) : bool
Parameters
- $name : string
Return values
boolhasWiths()
Determine if there are with relationships
public
hasWiths() : bool
Return values
boolincrement()
Increment the record column and save
public
increment(string $column[, int $amount = 1 ]) : void
Parameters
- $column : string
- $amount : int = 1
isDirty()
Check if row is dirty
public
isDirty() : bool
Return values
boolisFillable()
Determine if a column is mass-assignable via fill()
public
isFillable(string $column) : bool
Parameters
- $column : string
Return values
boolisTransaction()
Is transaction
public
isTransaction() : bool
Return values
boollatest()
Method to set latest flag for relationships
public
latest([string $sortBy = 'id' ]) : static
Parameters
- $sortBy : string = 'id'
Return values
staticoffsetExists()
ArrayAccess offsetExists
public
offsetExists(mixed $offset) : bool
Parameters
- $offset : mixed
Return values
booloffsetGet()
ArrayAccess offsetGet
public
offsetGet(mixed $offset) : mixed
Parameters
- $offset : mixed
offsetSet()
ArrayAccess offsetSet
public
offsetSet(mixed $offset, mixed $value) : void
Parameters
- $offset : mixed
- $value : mixed
offsetUnset()
ArrayAccess offsetUnset
public
offsetUnset(mixed $offset) : void
Parameters
- $offset : mixed
oldest()
Method to set oldest flag for relationships
public
oldest([string $sortBy = 'id' ]) : static
Parameters
- $sortBy : string = 'id'
Return values
staticparseColumns()
Parse columns and return expressions and params
public
parseColumns(array<string|int, mixed>|PredicateSet $columns) : array<string|int, mixed>
Parameters
- $columns : array<string|int, mixed>|PredicateSet
Return values
array<string|int, mixed>predicate()
Get a predicate set
public
static predicate([mixed $predicates = null ][, string|null $conjunction = null ]) : PredicateSet
Parameters
- $predicates : mixed = null
- $conjunction : string|null = null
Return values
PredicateSetprocessRow()
Process a table row
public
processRow(array<string|int, mixed> $row[, bool $toArray = false ]) : mixed
Parameters
- $row : array<string|int, mixed>
- $toArray : bool = false
processRows()
Process table rows
public
processRows(array<string|int, mixed> $rows[, bool $toArray = false ]) : array<string|int, mixed>
Parameters
- $rows : array<string|int, mixed>
- $toArray : bool = false
Return values
array<string|int, mixed>processWithRelationships()
Process with relationships
public
processWithRelationships(array<string|int, mixed> $rows) : AbstractRecord
Parameters
- $rows : array<string|int, mixed>
Return values
AbstractRecordquery()
Static method to execute a custom SQL query.
public
static query(mixed $sql[, bool $toArray = false ]) : Collection|array<string|int, mixed>|int
Parameters
- $sql : mixed
- $toArray : bool = false
Return values
Collection|array<string|int, mixed>|intreplicate()
Replicate the record
public
replicate([array<string|int, mixed> $replace = [] ]) : static
Parameters
- $replace : array<string|int, mixed> = []
Return values
staticreset()
Reset/clear the record column and save
public
reset(string $column[, mixed $value = null ]) : void
Parameters
- $column : string
- $value : mixed = null
resetDirty()
Reset row's dirty columns
public
resetDirty() : void
rollback()
Rollback transaction with the DB adapter
public
static rollback([Exception|null $exception = null ]) : Exception|null
The adapter's transaction manager already handles nesting: at depth 1 this performs a real ROLLBACK, at any greater depth it rolls back to (and releases) that level's savepoint. Either way the level is left, so the connection is never stranded inside an open transaction.
Parameters
- $exception : Exception|null = null
Tags
Return values
Exception|nullrollbackTransaction()
Rollback transaction
public
rollbackTransaction() : AbstractRecord
Tags
Return values
AbstractRecordrows()
Get the rows (alias method)
public
rows() : Collection
Return values
Collectionsave()
Save or update the record
public
save([array<string|int, mixed>|null $columns = null ][, bool $commit = true ]) : void
Parameters
- $columns : array<string|int, mixed>|null = null
- $commit : bool = true
Tags
setColumns()
Set all the table column values at once
public
setColumns([mixed $columns = null ]) : AbstractRecord
Parameters
- $columns : mixed = null
Tags
Return values
AbstractRecordsetDb()
Set DB adapter
public
static setDb(AbstractAdapter $db[, string|null $prefix = null ][, bool $isDefault = false ]) : void
Parameters
- $db : AbstractAdapter
- $prefix : string|null = null
- $isDefault : bool = false
setDefaultDb()
Set DB adapter
public
static setDefaultDb(AbstractAdapter $db) : void
Parameters
- $db : AbstractAdapter
setPrefix()
Set the table prefix
public
setPrefix(string $prefix) : AbstractRecord
Parameters
- $prefix : string
Return values
AbstractRecordsetPrimaryKeys()
Set the primary keys
public
setPrimaryKeys(array<string|int, mixed> $keys) : AbstractRecord
Parameters
- $keys : array<string|int, mixed>
Return values
AbstractRecordsetRelationship()
Set relationship
public
setRelationship(string $name, mixed $relationship) : AbstractRecord
Parameters
- $name : string
- $relationship : mixed
Return values
AbstractRecordsetRows()
Set all the table rows at once
public
setRows([array<string|int, mixed>|null $rows = null ][, bool $toArray = false ]) : AbstractRecord
Parameters
- $rows : array<string|int, mixed>|null = null
- $toArray : bool = false
Return values
AbstractRecordsetTable()
Set the table
public
setTable(string $table) : AbstractRecord
Parameters
- $table : string
Return values
AbstractRecordsetTableFromClassName()
Set the table from a class name
public
setTableFromClassName([string|null $class = null ]) : AbstractRecord
Parameters
- $class : string|null = null
Return values
AbstractRecordsql()
Get SQL builder (alias)
public
static sql() : Sql
Return values
Sqlstart()
Start transaction with the DB adapter. When called on a descendent class, construct a new object and use it for transaction management.
public
static start(mixed ...$constructorArgs) : static|null
Parameters
- $constructorArgs : mixed
-
Arguments passed to descendent class constructor
Tags
Return values
static|nullstartTransaction()
Start transaction
public
startTransaction() : AbstractRecord
Return values
AbstractRecordtable()
Get table name
public
static table([bool $quotes = false ]) : string
Parameters
- $quotes : bool = false
Return values
stringtoArray()
Get column values as array
public
toArray() : array<string|int, mixed>
Return values
array<string|int, mixed>transaction()
Execute complete transaction with the DB adapter
public
static transaction(mixed $callable[, mixed $params = null ]) : void
Parameters
- $callable : mixed
- $params : mixed = null
Tags
with()
With a 1:many relationship (eager-loading)
public
static with(mixed $name[, array<string|int, mixed>|null $options = null ]) : static
Parameters
- $name : mixed
- $options : array<string|int, mixed>|null = null
Return values
staticafterDelete()
Called after a single-record delete
protected
afterDelete() : void
afterInsert()
Called after a single-record insert
protected
afterInsert() : void
afterSave()
Called after a single-record save() (both insert and update)
protected
afterSave() : void
afterUpdate()
Called after a single-record update
protected
afterUpdate() : void
beforeDelete()
Called before a single-record delete
protected
beforeDelete() : void
beforeInsert()
Called before a single-record insert (a new record being saved for the first time)
protected
beforeInsert() : void
beforeSave()
Called before a single-record save() (both insert and update)
protected
beforeSave() : void
beforeUpdate()
Called before a single-record update (an existing record being saved again)
protected
beforeUpdate() : void
buildBetweenConditionColumns()
Build the structured shorthand columns tuple for a findWhereBetween()/findWhereNotBetween() condition
protected
static buildBetweenConditionColumns(string $condition, string $column, mixed $value) : array<string|int, mixed>
Parameters
- $condition : string
- $column : string
- $value : mixed
Return values
array<string|int, mixed>buildWhereConditionColumns()
Build the structured shorthand columns tuple for a findWhere*() condition
protected
static buildWhereConditionColumns(string $condition, string $column, mixed $value) : array<string|int, mixed>|null
Parameters
- $condition : string
- $column : string
- $value : mixed
Return values
array<string|int, mixed>|nullnewUnfilteredRecord()
Create a new record instance from trusted, internally-sourced column data
protected
static newUnfilteredRecord([array<string|int, mixed>|null $columns = null ]) : static
Mass-assignment filtering ($fillable/$guarded via fill()) is deliberately bypassed here. It exists to protect against untrusted external input being passed into the constructor, not against the component's own internal data flows (replicating an already-fetched record, or creating a record from the very search criteria that were just queried). Filtering those would silently drop column values and corrupt the resulting row.
Parameters
- $columns : array<string|int, mixed>|null = null
Tags
Return values
staticparseBetweenValues()
Normalize a findWhereBetween()/findWhereNotBetween() value into its two boundary values
protected
static parseBetweenValues(mixed $value) : array<string|int, mixed>|null
The documented calling convention packs both boundaries into a single string, '(value1, value2)' or '(value1 AND value2)' - the same shape the legacy shorthand parser accepts. A 2-element array is also accepted, and is the unambiguous form. Returns null if the value matches neither shape, in which case the caller leaves it to the legacy path.
Parameters
- $value : mixed
Return values
array<string|int, mixed>|nullparseFindWhereArguments()
Parse the (column, value, options, toArray) arguments for a findWhere*() call
protected
static parseFindWhereArguments(string $condition, array<string|int, mixed> $arguments) : array<string|int, mixed>
The 'Null'/'NotNull' conditions take no value argument, so $options and $toArray shift down by one argument position relative to every other condition.
Parameters
- $condition : string
- $arguments : array<string|int, mixed>
Return values
array<string|int, mixed>toColumnsArray()
Normalize a columns argument (array, ArrayObject, AbstractRecord, or any ArrayAccess with a toArray() method) into a plain array
protected
toColumnsArray(mixed $columns) : array<string|int, mixed>
Parameters
- $columns : mixed