AbstractDataModel
extends AbstractModel
in package
implements
DataModelInterface
Abstract data model class
Tags
Table of Contents
Interfaces
- DataModelInterface
- Data model interface
Properties
- $data : mixed
- Array data
- $filters : array<string|int, mixed>
- Filters
- $foreignTables : array<string|int, mixed>
- Foreign tables - List of foreign tables and columns to use in general select queries as JOINS [ 'table' => 'foreign_table', 'columns' => ['foreign_table.id' => 'table.foreign_id'] ]
- $options : array<string|int, mixed>
- Options
- $privateColumns : array<string|int, mixed>
- Private columns - Columns of sensitive data to hide from general select queries (i.e. passwords, etc.)
- $requirements : array<string|int, mixed>
- Requirements
- $selectColumns : array<string|int, mixed>
- Select columns - Columns to show for general select queries. Can include foreign columns if the $foreignTables property is properly configured
- $table : string|null
- Data table class
- $origSelectColumns : array<string|int, mixed>
- Original select columns - Property to track original select columns
Methods
- __construct() : mixed
- Constructor
- __get() : mixed
- Get a value
- __isset() : bool
- Is value set
- __serialize() : mixed
- Serialize magic method
- __set() : static
- Magic method to set the property to the value of $this->data[$name]
- __unserialize() : ArrayObject
- Unserialize magic method
- __unset() : void
- Unset a value
- contains() : bool
- Determine if an item exists in the array
- copy() : array<string|int, mixed>|Record
- Copy
- count() : int
- Get count
- create() : array<string|int, mixed>|Record
- Create
- createFromJson() : ArrayObject
- Create array object from JSON string
- createFromSerialized() : ArrayObject
- Create array object from serialized string
- createNew() : array<string|int, mixed>|Record
- Create new
- current() : mixed
- Get the current item of the array
- delete() : int
- Delete
- describe() : array<string|int, mixed>
- Method to describe columns in the database table
- fetch() : array<string|int, mixed>|Record
- Fetch by ID
- fetchAll() : array<string|int, mixed>|Collection
- Fetch all
- filter() : AbstractDataModel
- Set filters
- filterBy() : static
- Filter by
- first() : mixed
- Get the first item of the array
- getAll() : array<string|int, mixed>|Collection
- Get all
- getById() : array<string|int, mixed>|Record
- Get by ID
- getIterator() : ArrayIterator
- Method to iterate over the array object
- getOffsetAndLimit() : array<string|int, mixed>
- Get offset and limit
- getOrderBy() : string|array<string|int, mixed>|null
- Get order by
- getPrimaryId() : string
- Get table primary ID
- getTableClass() : string
- Get table class
- hasRequirements() : bool
- Method to check if model has requirements
- join() : string
- Join the array values into a string
- jsonSerialize() : string
- JSON serialize the array object
- jsonUnserialize() : ArrayObject
- Unserialize a JSON string
- key() : mixed
- Get the key of the current item of the array
- ksort() : array<string|int, mixed>
- Sort array by keys
- ksortDesc() : static
- Sort array by keys, descending
- last() : mixed
- Get the last item of the array
- next() : mixed
- Get the next item of the array
- offsetExists() : bool
- ArrayAccess offsetExists
- offsetGet() : mixed
- ArrayAccess offsetGet
- offsetSet() : void
- ArrayAccess offsetSet
- offsetUnset() : void
- ArrayAccess offsetUnset
- parseFilter() : array<string|int, mixed>
- Method to parse filter for select predicates
- remove() : int
- Remove multiple
- replace() : array<string|int, mixed>|Record
- Replace
- select() : AbstractDataModel
- Set (override) select columns
- serialize() : string
- Serialize the array object
- sort() : array<string|int, mixed>
- Sort array
- sortDesc() : static
- Sort array descending
- split() : static
- Split a string into an array object
- toArray() : array<string|int, mixed>
- Get the values as an array
- uksort() : array<string|int, mixed>
- Sort array by user-defined callback using keys
- unserialize() : ArrayObject
- Unserialize a string
- update() : array<string|int, mixed>|Record
- Update
- usort() : static
- Sort array by user-defined callback
- validate() : bool|array<string|int, mixed>
- Method to validate model data
Properties
$data
Array data
protected
mixed
$data
= null
$filters
Filters
protected
array<string|int, mixed>
$filters
= []
$foreignTables
Foreign tables - List of foreign tables and columns to use in general select queries as JOINS [ 'table' => 'foreign_table', 'columns' => ['foreign_table.id' => 'table.foreign_id'] ]
protected
array<string|int, mixed>
$foreignTables
= []
$options
Options
protected
array<string|int, mixed>
$options
= []
$privateColumns
Private columns - Columns of sensitive data to hide from general select queries (i.e. passwords, etc.)
protected
array<string|int, mixed>
$privateColumns
= []
$requirements
Requirements
protected
array<string|int, mixed>
$requirements
= []
$selectColumns
Select columns - Columns to show for general select queries. Can include foreign columns if the $foreignTables property is properly configured
protected
array<string|int, mixed>
$selectColumns
= []
$table
Data table class
protected
string|null
$table
= null
$origSelectColumns
Original select columns - Property to track original select columns
private
array<string|int, mixed>
$origSelectColumns
= []
Methods
__construct()
Constructor
public
__construct([mixed|null $data = null ]) : mixed
Instantiate the array object
Parameters
- $data : mixed|null = null
Tags
__get()
Get a value
public
__get(string $name) : mixed
Parameters
- $name : string
__isset()
Is value set
public
__isset(string $name) : bool
Parameters
- $name : string
Return values
bool__serialize()
Serialize magic method
public
__serialize() : mixed
__set()
Magic method to set the property to the value of $this->data[$name]
public
__set([string|null $name = null ][, mixed $value = null ]) : static
Parameters
- $name : string|null = null
- $value : mixed = null
Return values
static__unserialize()
Unserialize magic method
public
__unserialize(array<string|int, mixed> $data) : ArrayObject
Parameters
- $data : array<string|int, mixed>
Return values
ArrayObject__unset()
Unset a value
public
__unset(string $name) : void
Parameters
- $name : string
contains()
Determine if an item exists in the array
public
contains(mixed $key[, bool $strict = false ]) : bool
Parameters
- $key : mixed
- $strict : bool = false
Return values
boolcopy()
Copy
public
copy(mixed $id[, array<string|int, mixed> $replace = [] ][, bool $toArray = false ]) : array<string|int, mixed>|Record
Parameters
- $id : mixed
- $replace : array<string|int, mixed> = []
- $toArray : bool = false
Tags
Return values
array<string|int, mixed>|Recordcount()
Get count
public
count() : int
Tags
Return values
intcreate()
Create
public
create(array<string|int, mixed> $data[, bool $toArray = false ]) : array<string|int, mixed>|Record
Parameters
- $data : array<string|int, mixed>
- $toArray : bool = false
Tags
Return values
array<string|int, mixed>|RecordcreateFromJson()
Create array object from JSON string
public
static createFromJson(string $jsonString[, int $depth = 512 ][, int $options = 0 ]) : ArrayObject
Parameters
- $jsonString : string
- $depth : int = 512
- $options : int = 0
Return values
ArrayObjectcreateFromSerialized()
Create array object from serialized string
public
static createFromSerialized(string $string) : ArrayObject
Parameters
- $string : string
Tags
Return values
ArrayObjectcreateNew()
Create new
public
static createNew(array<string|int, mixed> $data[, bool $toArray = false ]) : array<string|int, mixed>|Record
Parameters
- $data : array<string|int, mixed>
- $toArray : bool = false
Tags
Return values
array<string|int, mixed>|Recordcurrent()
Get the current item of the array
public
current() : mixed
delete()
Delete
public
delete(mixed $id) : int
Parameters
- $id : mixed
Tags
Return values
intdescribe()
Method to describe columns in the database table
public
describe([bool $native = false ][, bool $full = false ]) : array<string|int, mixed>
Parameters
- $native : bool = false
-
Show only the native columns in the table
- $full : bool = false
-
Used with the native flag, returns a full descriptive array of table info
Tags
Return values
array<string|int, mixed>fetch()
Fetch by ID
public
static fetch(mixed $id[, bool $toArray = false ]) : array<string|int, mixed>|Record
Parameters
- $id : mixed
- $toArray : bool = false
Tags
Return values
array<string|int, mixed>|RecordfetchAll()
Fetch all
public
static fetchAll([string|null $sort = null ][, mixed $limit = null ][, mixed $page = null ][, bool|array<string|int, mixed> $toArray = false ]) : array<string|int, mixed>|Collection
Parameters
- $sort : string|null = null
- $limit : mixed = null
- $page : mixed = null
- $toArray : bool|array<string|int, mixed> = false
Tags
Return values
array<string|int, mixed>|Collectionfilter()
Set filters
public
filter([mixed $filters = null ][, mixed $select = null ][, array<string|int, mixed>|null $options = null ]) : AbstractDataModel
Parameters
- $filters : mixed = null
- $select : mixed = null
- $options : array<string|int, mixed>|null = null
Return values
AbstractDataModelfilterBy()
Filter by
public
static filterBy([mixed $filters = null ][, mixed $select = null ]) : static
Parameters
- $filters : mixed = null
- $select : mixed = null
Return values
staticfirst()
Get the first item of the array
public
first() : mixed
getAll()
Get all
public
getAll([string|null $sort = null ][, mixed $limit = null ][, mixed $page = null ][, bool|array<string|int, mixed> $toArray = false ]) : array<string|int, mixed>|Collection
Parameters
- $sort : string|null = null
- $limit : mixed = null
- $page : mixed = null
- $toArray : bool|array<string|int, mixed> = false
Tags
Return values
array<string|int, mixed>|CollectiongetById()
Get by ID
public
getById(mixed $id[, bool $toArray = false ]) : array<string|int, mixed>|Record
Parameters
- $id : mixed
- $toArray : bool = false
Tags
Return values
array<string|int, mixed>|RecordgetIterator()
Method to iterate over the array object
public
getIterator() : ArrayIterator
Return values
ArrayIteratorgetOffsetAndLimit()
Get offset and limit
public
getOffsetAndLimit([mixed $page = null ][, mixed $limit = null ]) : array<string|int, mixed>
Parameters
- $page : mixed = null
- $limit : mixed = null
Return values
array<string|int, mixed>getOrderBy()
Get order by
public
getOrderBy([mixed $sort = null ][, bool $toArray = false ]) : string|array<string|int, mixed>|null
Parameters
- $sort : mixed = null
- $toArray : bool = false
Return values
string|array<string|int, mixed>|nullgetPrimaryId()
Get table primary ID
public
getPrimaryId() : string
Return values
stringgetTableClass()
Get table class
public
getTableClass() : string
Tags
Return values
stringhasRequirements()
Method to check if model has requirements
public
hasRequirements() : bool
Return values
booljoin()
Join the array values into a string
public
join(string $glue[, string $finalGlue = '' ]) : string
Parameters
- $glue : string
- $finalGlue : string = ''
Return values
stringjsonSerialize()
JSON serialize the array object
public
jsonSerialize([int $options = 0 ][, int $depth = 512 ]) : string
Parameters
- $options : int = 0
- $depth : int = 512
Return values
stringjsonUnserialize()
Unserialize a JSON string
public
jsonUnserialize(string $jsonString[, int $depth = 512 ][, int $options = 0 ]) : ArrayObject
Parameters
- $jsonString : string
- $depth : int = 512
- $options : int = 0
Return values
ArrayObjectkey()
Get the key of the current item of the array
public
key() : mixed
ksort()
Sort array by keys
public
ksort([int $flags = SORT_REGULAR ][, bool $descending = false ]) : array<string|int, mixed>
Parameters
- $flags : int = SORT_REGULAR
- $descending : bool = false
Return values
array<string|int, mixed>ksortDesc()
Sort array by keys, descending
public
ksortDesc([int $flags = SORT_REGULAR ]) : static
Parameters
- $flags : int = SORT_REGULAR
Return values
staticlast()
Get the last item of the array
public
last() : mixed
next()
Get the next item of the array
public
next() : mixed
offsetExists()
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
parseFilter()
Method to parse filter for select predicates
public
parseFilter(mixed $filter) : array<string|int, mixed>
Parameters
- $filter : mixed
Return values
array<string|int, mixed>remove()
Remove multiple
public
remove(array<string|int, mixed> $ids) : int
Parameters
- $ids : array<string|int, mixed>
Tags
Return values
intreplace()
Replace
public
replace(mixed $id, array<string|int, mixed> $data[, bool $toArray = false ]) : array<string|int, mixed>|Record
Parameters
- $id : mixed
- $data : array<string|int, mixed>
- $toArray : bool = false
Tags
Return values
array<string|int, mixed>|Recordselect()
Set (override) select columns
public
select([mixed $select = null ][, array<string|int, mixed>|null $options = null ]) : AbstractDataModel
Parameters
- $select : mixed = null
- $options : array<string|int, mixed>|null = null
Return values
AbstractDataModelserialize()
Serialize the array object
public
serialize([bool $self = false ]) : string
Parameters
- $self : bool = false
Return values
stringsort()
Sort array
public
sort([int $flags = SORT_REGULAR ][, bool $assoc = true ][, bool $descending = false ]) : array<string|int, mixed>
Parameters
- $flags : int = SORT_REGULAR
- $assoc : bool = true
- $descending : bool = false
Return values
array<string|int, mixed>sortDesc()
Sort array descending
public
sortDesc([int $flags = SORT_REGULAR ][, bool $assoc = true ]) : static
Parameters
- $flags : int = SORT_REGULAR
- $assoc : bool = true
Return values
staticsplit()
Split a string into an array object
public
static split(string $string, string $separator[, int $limit = PHP_INT_MAX ]) : static
Parameters
- $string : string
- $separator : string
- $limit : int = PHP_INT_MAX
Return values
statictoArray()
Get the values as an array
public
toArray() : array<string|int, mixed>
Return values
array<string|int, mixed>uksort()
Sort array by user-defined callback using keys
public
uksort(mixed $callback) : array<string|int, mixed>
Parameters
- $callback : mixed
Return values
array<string|int, mixed>unserialize()
Unserialize a string
public
unserialize(string $string) : ArrayObject
Parameters
- $string : string
Tags
Return values
ArrayObjectupdate()
Update
public
update(mixed $id, array<string|int, mixed> $data[, bool $toArray = false ]) : array<string|int, mixed>|Record
Parameters
- $id : mixed
- $data : array<string|int, mixed>
- $toArray : bool = false
Tags
Return values
array<string|int, mixed>|Recordusort()
Sort array by user-defined callback
public
usort(mixed $callback[, bool $assoc = true ]) : static
Parameters
- $callback : mixed
- $assoc : bool = true
Return values
staticvalidate()
Method to validate model data
public
validate(array<string|int, mixed> $data) : bool|array<string|int, mixed>
Parameters
- $data : array<string|int, mixed>