Documentation

OTFModel extends Model
in package

This class allows to track changes on database data along the use of a program and creates interactions with the database in a safe way.

Table of Contents

$data  : array<string|int, AdapterInterface>
The actual data that the record contains. The record is basically a wrapper around the array that allows to validate data on the go and to alert the programmer about inconsistent types.
$new  : mixed
$table  : Table
Keeps information about the table that owns the record this Model represents.
__construct()  : mixed
Creates a new record.
__get()  : mixed
__isset()  : mixed
__set()  : mixed
__toString()  : mixed
definitions()  : Schema
This method is used to generate the 'template' for the table that allows spitfire to automatically generate tables and allows it to check the types of data and fix tables.
delete()  : mixed
getData()  : mixed
Returns the data this record currently contains as associative array.
getDependencies()  : Collection
getPrimaryData()  : array<string|int, mixed>
Returns the values of the fields included in this records primary fields
getQuery()  : mixed
getTable()  : Table
Returns the table this record belongs to.
increment()  : mixed
Increments a value on high read/write environments. Using update can cause data to be corrupted. Increment requires the data to be in sync aka. stored to database.
isNew()  : mixed
jsonSerialize()  : array<string|int, mixed>
The jsonserialize endpoint allows applications to json_encode this model without having to loop over all the keys.
onbeforesave()  : void
Allows the model to perform small tasks before it is written to the database.
serialize()  : mixed
store()  : mixed
This method stores the data of this record to the database. In case of database error it throws an Exception and leaves the state of the record unchanged.
unserialize()  : mixed
write()  : mixed
makeAdapters()  : mixed
populateAdapters()  : mixed

Properties

$data

The actual data that the record contains. The record is basically a wrapper around the array that allows to validate data on the go and to alert the programmer about inconsistent types.

private array<string|int, AdapterInterface> $data

$new

private mixed $new = false

$table

Keeps information about the table that owns the record this Model represents.

private Table $table

This allows it to power functions like store that require knowledge about the database keeping the information.

Methods

__construct()

Creates a new record.

public __construct([Table $table = null ][, mixed $data = null ]) : mixed
Parameters
$table : Table = null

DB Table this record belongs to. Easiest way to get this is by using $this->model->tablename

$data : mixed = null

Attention! This parameter is intended to be used by the system. To create a new record, leave empty and use setData.

Return values
mixed

__get()

public __get(mixed $field) : mixed
Parameters
$field : mixed
Return values
mixed

__isset()

public __isset(mixed $name) : mixed
Parameters
$name : mixed
Return values
mixed

__set()

public __set(mixed $field, mixed $value) : mixed
Parameters
$field : mixed
$value : mixed
Return values
mixed

__toString()

public __toString() : mixed
Return values
mixed

definitions()

This method is used to generate the 'template' for the table that allows spitfire to automatically generate tables and allows it to check the types of data and fix tables.

public definitions(Schema $schema) : Schema
Parameters
$schema : Schema
Return values
Schema

delete()

public delete() : mixed
Return values
mixed

getData()

Returns the data this record currently contains as associative array.

public getData() : mixed

Remember that this data COULD be invalid when using setData to provide it.

Return values
mixed

getDependencies()

public getDependencies() : Collection
Tags
deprecated

since version 0.1-dev 20190611

Return values
Collection

getPrimaryData()

Returns the values of the fields included in this records primary fields

public getPrimaryData() : array<string|int, mixed>
Tags
todo

Find better function name

Return values
array<string|int, mixed>

getQuery()

public getQuery() : mixed
Return values
mixed

getTable()

Returns the table this record belongs to.

public getTable() : Table
Return values
Table

increment()

Increments a value on high read/write environments. Using update can cause data to be corrupted. Increment requires the data to be in sync aka. stored to database.

public increment(string $key[, int|float $diff = 1 ]) : mixed
Parameters
$key : string
$diff : int|float = 1
Tags
throws
PrivateException
Return values
mixed

isNew()

public isNew() : mixed
Return values
mixed

jsonSerialize()

The jsonserialize endpoint allows applications to json_encode this model without having to loop over all the keys.

public jsonSerialize() : array<string|int, mixed>

If your application wishes to not expose certain data to the outside world, feel free to implement jsonSerialize in your model and unset the keys you do not wish to broadcast.

This method is intended to aid passing data to views and rendering output, the data exported here cannot be imported back into spitfire.

Return values
array<string|int, mixed>

onbeforesave()

Allows the model to perform small tasks before it is written to the database.

public onbeforesave() : void
Return values
void

This method does not return

serialize()

public serialize() : mixed
Return values
mixed

store()

This method stores the data of this record to the database. In case of database error it throws an Exception and leaves the state of the record unchanged.

public store() : mixed
Tags
throws
PrivateException
Return values
mixed

unserialize()

public unserialize(mixed $serialized) : mixed
Parameters
$serialized : mixed
Return values
mixed

write()

public write() : mixed
Tags
deprecated

since version 0.1-dev 20190611

Return values
mixed

makeAdapters()

protected makeAdapters() : mixed
Return values
mixed

populateAdapters()

protected populateAdapters(mixed $data) : mixed
Parameters
$data : mixed
Return values
mixed

Search results