Documentation

Encoded extends Record
in package

Encoded record class

Tags
category

Pop

author

Nick Sagona, III nick@popphp.org

copyright

Copyright (c) 2009-2026 Nick Sagona, III

license

https://www.popphp.org/license New BSD License

version
7.0.0

Table of Contents

Properties

$base64Fields  : array<string|int, mixed>
Base64-encoded fields
$cipherMethod  : string|null
Encryption cipher method
$currentWithIndex  : int
Current with index
$encryptedFields  : array<string|int, mixed>
Encrypted fields
$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
$hashAlgorithm  : string
Hash algorithm
$hashFields  : array<string|int, mixed>
Password-hashed fields
$hashOptions  : array<string|int, mixed>
Hash options
$isNew  : bool
Is new record flag
$isTransaction  : bool
Is transaction flag
$jsonFields  : array<string|int, mixed>
JSON-encoded fields
$key  : string|null
Encryption key
$latest  : bool
Relationship latest flag
$needsRehash  : bool
Whether the last verified hash needs to be rehashed
$oldest  : bool
Relationship oldest flag
$phpFields  : array<string|int, mixed>
PHP-serialized fields
$prefix  : string|null
Table prefix
$previousKeys  : array<string|int, mixed>
Encryption previous keys
$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)
decode()  : array<string|int, mixed>
Scrub the column values and decode them
decodeValue()  : mixed
Decode value
decrement()  : void
Decrement the record column and save
delete()  : void
Delete the record
encode()  : array<string|int, mixed>
Scrub the column values and encode them
encodeValue()  : string
Encode value
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
getRawValue()  : mixed
Get raw un-encoded value
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
isEncodedColumn()  : bool
Determine if column is an encoded column
isFillable()  : bool
Determine if a column is mass-assignable via fill()
isTransaction()  : bool
Is transaction
latest()  : static
Method to set latest flag for relationships
loadEncryptionProperties()  : void
Attempt to load encryption properties from $_ENV vars
needsRehash()  : bool
Determine if the last verified hash needs to be rehashed
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.
rehash()  : void
Rehash and save the given field with a freshly-hashed value
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()  : Encoded
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
verify()  : bool
Verify value against hash
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

$base64Fields

Base64-encoded fields

protected array<string|int, mixed> $base64Fields = []

$cipherMethod

Encryption cipher method

protected string|null $cipherMethod = null

$currentWithIndex

Current with index

protected int $currentWithIndex = 0

$encryptedFields

Encrypted fields

protected array<string|int, mixed> $encryptedFields = []

$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 = []

$hashAlgorithm

Hash algorithm

protected string $hashAlgorithm = PASSWORD_BCRYPT

$hashFields

Password-hashed fields

protected array<string|int, mixed> $hashFields = []

$hashOptions

Hash options

protected array<string|int, mixed> $hashOptions = []

$isTransaction

Is transaction flag

protected bool $isTransaction = false

$jsonFields

JSON-encoded fields

protected array<string|int, mixed> $jsonFields = []

$key

Encryption key

protected string|null $key = null

$latest

Relationship latest flag

protected bool $latest = false

$needsRehash

Whether the last verified hash needs to be rehashed

protected bool $needsRehash = false

$oldest

Relationship oldest flag

protected bool $oldest = false

$phpFields

PHP-serialized fields

protected array<string|int, mixed> $phpFields = []

$previousKeys

Encryption previous keys

protected array<string|int, mixed> $previousKeys = []

$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'

$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
throws
Exception|Exception

__get()

Magic method to return the value of $this->rowGateway[$name]

public __get(string $name) : mixed
Parameters
$name : string
Tags
throws
Exception

__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
Tags
throws
Exception

__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
AbstractRecord

belongsTo()

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|BelongsTo

commit()

Commit transaction with the DB adapter

public static commit() : void
Tags
throws
Exception

copy()

Copy the record (alias to replicate)

public copy([array<string|int, mixed> $replace = [] ]) : static
Parameters
$replace : array<string|int, mixed> = []
Return values
static

count()

Method to get count of fields in row gateway

public count() : int
Return values
int

countRows()

Get the count of rows returned in the result

public countRows() : int
Return values
int

decode()

Scrub the column values and decode them

public decode(array<string|int, mixed> $columns) : array<string|int, mixed>
Parameters
$columns : array<string|int, mixed>
Tags
throws
Exception
Return values
array<string|int, mixed>

decodeValue()

Decode value

public decodeValue(string $key, string $value) : mixed
Parameters
$key : string
$value : string
Tags
throws
Exception

decrement()

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

encode()

Scrub the column values and encode them

public encode(array<string|int, mixed> $columns) : array<string|int, mixed>
Parameters
$columns : array<string|int, mixed>
Tags
throws
Exception
Return values
array<string|int, mixed>

encodeValue()

Encode value

public encodeValue(string $key, mixed $value) : string
Parameters
$key : string
$value : mixed
Tags
throws
Exception
Return values
string

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>|int

findAll()

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>|static

findBy()

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
static

findWhereEquals()

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
static

findWhereGreaterThan()

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
static

findWhereGreaterThanOrEqual()

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
static

findWhereIn()

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
static

findWhereLessThan()

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
static

findWhereLessThanOrEqual()

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
static

findWhereLike()

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
static

findWhereNotBetween()

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
static

findWhereNotEquals()

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
static

findWhereNotIn()

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
static

findWhereNotLike()

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
static

findWhereNotNull()

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
static

findWhereNull()

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
static

getAll()

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>

getDirty()

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
string

getIn()

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
ArrayIterator

getOne()

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|null

getPrimaryKeys()

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>

getRawValue()

Get raw un-encoded value

public getRawValue(string $name) : mixed
Parameters
$name : string

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>

getSql()

Get SQL builder

public static getSql() : Sql
Return values
Sql

getTable()

Get the table

public getTable() : string|null
Return values
string|null

getTableInfo()

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
int

getWiths()

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
bool

hasMany()

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|HasOne

hasOneOf()

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|HasOneOf

hasRelationship()

Has relationship

public hasRelationship(string $name) : bool
Parameters
$name : string
Return values
bool

hasRelationships()

Get relationships

public hasRelationships() : bool
Return values
bool

hasRows()

Determine if the result has rows

public hasRows() : bool
Return values
bool

hasWith()

Determine if there is specific with relationship

public hasWith(string $name) : bool
Parameters
$name : string
Return values
bool

hasWiths()

Determine if there are with relationships

public hasWiths() : bool
Return values
bool

increment()

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
bool

isEncodedColumn()

Determine if column is an encoded column

public isEncodedColumn(string $key) : bool
Parameters
$key : string
Return values
bool

isFillable()

Determine if a column is mass-assignable via fill()

public isFillable(string $column) : bool
Parameters
$column : string
Return values
bool

isTransaction()

Is transaction

public isTransaction() : bool
Return values
bool

latest()

Method to set latest flag for relationships

public latest([string $sortBy = 'id' ]) : static
Parameters
$sortBy : string = 'id'
Return values
static

loadEncryptionProperties()

Attempt to load encryption properties from $_ENV vars

public loadEncryptionProperties() : void

needsRehash()

Determine if the last verified hash needs to be rehashed

public needsRehash() : bool
Return values
bool

offsetExists()

ArrayAccess offsetExists

public offsetExists(mixed $offset) : bool
Parameters
$offset : mixed
Return values
bool

offsetGet()

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
static

parseColumns()

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
PredicateSet

processRow()

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
AbstractRecord

query()

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>|int

rehash()

Rehash and save the given field with a freshly-hashed value

public rehash(string $key, string $value) : void
Parameters
$key : string
$value : string

replicate()

Replicate the record

public replicate([array<string|int, mixed> $replace = [] ]) : static
Parameters
$replace : array<string|int, mixed> = []
Return values
static

reset()

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
throws
Exception
Return values
Exception|null

save()

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
throws
Exception

setColumns()

Set all the table column values at once

public setColumns([mixed $columns = null ]) : Encoded
Parameters
$columns : mixed = null
Tags
throws
Exception
Return values
Encoded

setDb()

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

setRows()

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
AbstractRecord

sql()

Get SQL builder (alias)

public static sql() : Sql
Return values
Sql

start()

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
throws
Exception|Exception
Return values
static|null

table()

Get table name

public static table([bool $quotes = false ]) : string
Parameters
$quotes : bool = false
Return values
string

toArray()

Get column values as array

public toArray() : array<string|int, mixed>
Tags
throws
Exception
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
throws
Exception

verify()

Verify value against hash

public verify(string $key, string $value[, bool $autoRehash = true ]) : bool

Also records whether the stored hash needs to be rehashed (outdated algorithm/cost), queryable via needsRehash() and actionable via rehash()

Parameters
$key : string
$value : string
$autoRehash : bool = true
Return values
bool

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
static

afterDelete()

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>|null

newUnfilteredRecord()

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
throws
Exception|Exception
Return values
static

parseBetweenValues()

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>|null

parseFindWhereArguments()

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
Tags
throws
Exception
Return values
array<string|int, mixed>

        
On this page

Search results