Documentation

AuditableModel extends AbstractDataModel
in package
implements AuditableInterface

AbstractYes

Abstract auditable model class

Tags
category

Pop

author

Nick Sagona, III dev@nolainteractive.com

copyright

Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com)

license

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

version
2.0.0

Table of Contents

Interfaces

AuditableInterface
Auditable model interface

Properties

$auditor  : Auditor|null
Auditor object
$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
Method to get the count of data in the collection
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
getAuditor()  : Auditor|null
Get the auditor object
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
hasAuditor()  : bool
Determine if the model has auditor
hasRequirements()  : bool
Method to check if model has requirements
isAuditable()  : bool
Determine if the model is auditable (alias)
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
setAuditor()  : AuditableModel
Set the auditor 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

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

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

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

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

copy()

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

count()

Method to get the count of data in the collection

public count() : int
Return values
int

create()

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

createFromJson()

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
ArrayObject

createFromSerialized()

Create array object from serialized string

public static createFromSerialized(string $string) : ArrayObject
Parameters
$string : string
Tags
throws
Exception
Return values
ArrayObject

createNew()

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

current()

Get the current item of the array

public current() : mixed

describe()

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

fetchAll()

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

filter()

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
AbstractDataModel

filterBy()

Filter by

public static filterBy([mixed $filters = null ][, mixed $select = null ]) : static
Parameters
$filters : mixed = null
$select : mixed = null
Return values
static

first()

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

getById()

Get by ID

public getById(mixed $id[, bool $toArray = false ]) : array<string|int, mixed>|Record
Parameters
$id : mixed
$toArray : bool = false
Tags
throws
Exception
Return values
array<string|int, mixed>|Record

getIterator()

Method to iterate over the array object

public getIterator() : ArrayIterator
Return values
ArrayIterator

getOffsetAndLimit()

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

getPrimaryId()

Get table primary ID

public getPrimaryId() : string
Return values
string

hasAuditor()

Determine if the model has auditor

public hasAuditor() : bool
Return values
bool

hasRequirements()

Method to check if model has requirements

public hasRequirements() : bool
Return values
bool

isAuditable()

Determine if the model is auditable (alias)

public isAuditable() : bool
Return values
bool

join()

Join the array values into a string

public join(string $glue[, string $finalGlue = '' ]) : string
Parameters
$glue : string
$finalGlue : string = ''
Return values
string

jsonSerialize()

JSON serialize the array object

public jsonSerialize([int $options = 0 ][, int $depth = 512 ]) : string
Parameters
$options : int = 0
$depth : int = 512
Return values
string

jsonUnserialize()

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
ArrayObject

key()

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
static

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

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

replace()

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

select()

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
AbstractDataModel

serialize()

Serialize the array object

public serialize([bool $self = false ]) : string
Parameters
$self : bool = false
Return values
string

sort()

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
static

split()

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
static

toArray()

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>

update()

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

usort()

Sort array by user-defined callback

public usort(mixed $callback[, bool $assoc = true ]) : static
Parameters
$callback : mixed
$assoc : bool = true
Return values
static

validate()

Method to validate model data

public validate(array<string|int, mixed> $data) : bool|array<string|int, mixed>
Parameters
$data : array<string|int, mixed>
Return values
bool|array<string|int, mixed>

        
On this page

Search results