|
static | tableScheme ($db_table) |
|
static | expireTableScheme () |
|
static | exists ($id) |
|
static | countBySql ($sql= '1', $params=[]) |
|
static | create ($data) |
|
static | buildExisting ($data) |
|
static | import ($data) |
|
static | findBySQL ($sql, $params=[]) |
|
static | findOneBySQL ($where, $params=[]) |
|
static | findThru ($foreign_key_value, $options) |
|
static | findEachBySQL ($callable, $sql, $params=[]) |
|
static | findMany ($pks=[], $order= '', $order_params=[]) |
|
static | findEachMany ($callable, $pks=[], $order= '', $order_params=[]) |
|
static | findAndMapBySQL ($callable, $where, $params=[]) |
|
static | findAndMapMany ($callable, $pks=[], $order= '', $order_params=[]) |
|
static | deleteBySQL ($where, $params=[]) |
|
static | toObject ($id_or_object) |
|
static | __callStatic ($name, $arguments) |
|
__construct |
( |
|
$id = null | ) |
|
constructor, give primary key of record as param to fetch corresponding record from db if available, if not preset primary key with given value. Give null to create new record
- Parameters
-
null | int | string | array | $id | primary key of table |
static __callStatic |
( |
|
$name, |
|
|
|
$arguments |
|
) |
| |
|
static |
interceptor for static findByColumn / findEachByColumn / countByColumn / deleteByColumn magic
- Parameters
-
string | $name | |
array | $arguments | |
- Exceptions
-
- Returns
- int|static|static[]
clean up references after cloning
- Returns
- void
magic method for dynamic properties
- Exceptions
-
InvalidArgumentException | if column could not be found |
BadMethodCallException | if getter for additional field could not be found |
- Parameters
-
string | $field | the column or additional field |
- Returns
- null|string|SimpleORMapCollection
magic method for dynamic properties
- Parameters
-
- Returns
- bool
magic method for dynamic properties
- Exceptions
-
InvalidArgumentException | if column could not be found |
BadMethodCallException | if setter for additional field could not be found |
- Parameters
-
string | $field | |
string | $value | |
- Returns
- string
_getAdditionalValue |
( |
|
$field | ) |
|
|
protected |
_getAdditionalValueFromRelation |
( |
|
$field | ) |
|
|
protected |
retrieves an additional field value from relation
- Parameters
-
- Returns
- mixed
returns internal used id value (multiple keys concatenated with _)
- Parameters
-
mixed | $field | unused parameter |
- Returns
- ?string
_setAdditionalValue |
( |
|
$field, |
|
|
|
$value |
|
) |
| |
|
protected |
_setAdditionalValueFromRelation |
( |
|
$field, |
|
|
|
$value |
|
) |
| |
|
protected |
sets additional value in field imported from relation
- Parameters
-
- Returns
- mixed
_setId |
( |
|
$field, |
|
|
|
$value |
|
) |
| |
|
protected |
sets internal used id value (multiple keys concatenated with _)
- Parameters
-
string | $field | Field to set (unused since it's always the id) |
string | $value | Value for id field |
- Returns
- bool
static additional_fields |
( |
| ) |
|
|
staticprotected |
additional computed fields name => callable
- Returns
- array
aliases for columns alias => column
- Returns
- array
invoke registered callbacks for given type if one callback returns false the following will not be invoked
- Parameters
-
string | $type | type of callback |
- Returns
- bool return value from last callback
n:1 relations
- Returns
- array
static buildExisting |
( |
|
$data | ) |
|
|
static |
build object with given data and mark it as existing
- Parameters
-
array | $data | assoc array of record |
- Returns
- static
cbAfterInitialize |
( |
|
$cb_type | ) |
|
|
protected |
default callback used to map specific callbacks to NotificationCenter
- Parameters
-
string | $cb_type | callback type |
- Returns
- void|boolean
cbNotificationMapper |
( |
|
$cb_type | ) |
|
|
protected |
default callback used to map specific callbacks to NotificationCenter
- Parameters
-
string | $cb_type | callback type |
- Returns
- void|boolean
Cleans up this object. This essentially reset all relations of this object and marks them as unused so that the garbage collector may remove the objects.
Use this function when you ran into memory problems and need to free some memory;
- Returns
- void
fetch config data for the called class
- Parameters
-
- Returns
- mixed value of config key (null if not set)
static configure |
( |
|
$config = [] | ) |
|
|
staticprotected |
set configuration data from subclass
- Parameters
-
?array | $config configuration data |
- Returns
- void
static countBySql |
( |
|
$sql = '1' , |
|
|
|
$params = [] |
|
) |
| |
|
static |
returns number of records
- Parameters
-
?string | $sql sql clause to use on the right side of WHERE |
?array | $params params for query |
- Returns
- int
creates new record with given data in db returns the new object or null
- Parameters
-
array | $data | assoc array of record |
- Returns
- ?static
table columns
- Returns
- array
name of db table
- Returns
- string
static default_values |
( |
| ) |
|
|
staticprotected |
default values for columns
- Returns
- array
delete entry from database the object is cleared, but is not(!) turned to new state
- Returns
- bool|int number of deleted rows
static deleteBySQL |
( |
|
$where, |
|
|
|
$params = [] |
|
) |
| |
|
static |
deletes objects specified by sql clause
- Parameters
-
string | $where | sql clause to use on the right side of WHERE |
| ?array | $params parameters for query |
- Returns
- integer number of deleted records
sends a delete message to all related objects if a relation has a callback for 'on_delete' configured, the callback is invoked instead
- Returns
- bool|int addition of all return values, false if none was called
Returns true if given key exists in the database.
- Parameters
-
string | array | $id | primary key |
- Returns
- boolean
static expireTableScheme |
( |
| ) |
|
|
static |
force reload of cached table metadata
- Returns
- void
static findAndMapBySQL |
( |
|
$callable, |
|
|
|
$where, |
|
|
|
$params = [] |
|
) |
| |
|
static |
passes objects for given sql through given callback and returns an array of callback return values
- Parameters
-
callable | $callable | callback which gets the current record as param |
string | $where | where clause of sql |
array | $params | sql statement parameters |
- Returns
- array return values of callback
static findAndMapMany |
( |
|
$callable, |
|
|
|
$pks = [] , |
|
|
|
$order = '' , |
|
|
|
$order_params = [] |
|
) |
| |
|
static |
passes objects for by given pks through given callback and returns an array of callback return values
- Parameters
-
callable | $callable | callback which gets the current record as param |
| ?array | $pks array of primary keys of called class |
| ?string | $order order by sql |
| ?array | $order_params |
- Returns
- array return values of callback
static findBySQL |
( |
|
$sql, |
|
|
|
$params = [] |
|
) |
| |
|
static |
returns array of instances of given class filtered by given sql
- Parameters
-
string | $sql | sql clause to use on the right side of WHERE |
| ?array | $params parameters for query |
- Returns
- static[] array of "self" objects
static findEachBySQL |
( |
|
$callable, |
|
|
|
$sql, |
|
|
|
$params = [] |
|
) |
| |
|
static |
passes objects for given sql through given callback
- Parameters
-
callable | $callable | callback which gets the current record as param |
string | $sql | where clause of sql |
| ?array | $params sql statement parameters |
- Returns
- integer number of found records
static findEachMany |
( |
|
$callable, |
|
|
|
$pks = [] , |
|
|
|
$order = '' , |
|
|
|
$order_params = [] |
|
) |
| |
|
static |
passes objects for by given pks through given callback
- Parameters
-
callable | $callable | callback which gets the current record as param |
| ?array | $pks array of primary keys of called class |
| ?string | $order order by sql |
| ?array | $order_params |
- Returns
- integer number of found records
static findMany |
( |
|
$pks = [] , |
|
|
|
$order = '' , |
|
|
|
$order_params = [] |
|
) |
| |
|
static |
returns array of instances of given class for by given pks
- Parameters
-
?array | $pks array of primary keys |
?string | $order order by clause |
?array | $order_params |
- Returns
- static[]
static findOneBySQL |
( |
|
$where, |
|
|
|
$params = [] |
|
) |
| |
|
static |
returns one instance of given class filtered by given sql only first row of query is used
- Parameters
-
string | $where | sql clause to use on the right side of WHERE |
| ?array | $params parameters for query |
- Returns
- ?static
static findThru |
( |
|
$foreign_key_value, |
|
|
|
$options |
|
) |
| |
|
static |
find related records for a n:m relation (has_many_and_belongs_to_many) using a combination table holding the keys
- Parameters
-
string | $foreign_key_value | value of foreign key to find related records |
array | $options | relation options from other side of relation |
- Returns
- static[] array of "self" objects
getDefaultValue |
( |
|
$field | ) |
|
returns default value for column
- Parameters
-
string | $field | name of column |
- Returns
- mixed the default value
returns primary key, multiple keys as array
- Returns
- null|string|array current primary key, null if not set
IteratorAggregate
- Returns
- ArrayIterator
create new unique pk as md5 hash if pk consists of multiple columns, false is returned
- Returns
- boolean|string
getPristineValue |
( |
|
$field | ) |
|
returns unmodified value of given field
- Parameters
-
- Exceptions
-
- Returns
- mixed
getRelationOptions |
( |
|
$relation | ) |
|
returns array with option for given relation available options: 'type': relation type, on of 'has_many', 'belongs_to', 'has_one', 'has_and_belongs_to_many' 'class_name': name of class for related records 'foreign_key': name of column with foreign key or callback to retrieve foreign key value 'assoc_foreign_key': name of foreign key column in related class 'assoc_func': name of static method to call on related class to find related records 'assoc_func_params_func': callback to retrieve params for assoc_func 'thru_table': name of relation table for n:m relation 'thru_key': name of column holding foreign key in relation table 'thru_assoc_key': name of column holding foreign key from related class in relation table 'on_delete': contains simply 'delete' to indicate that related records should be deleted or callback to invoke before record gets deleted 'on_store': contains simply 'store' to indicate that related records should be stored or callback to invoke after record gets stored
- Parameters
-
string | $relation | name of relation |
- Returns
- array assoc array containing options
getRelationValue |
( |
|
$relation, |
|
|
|
$field |
|
) |
| |
gets a value from a related object only possible, if the relation has cardinality 1 e.g. 'has_one' or 'belongs_to'
- Parameters
-
string | $relation | name of relation |
string | $field | name of column |
- Exceptions
-
InvalidArgumentException | if no relation with given name is found |
- Returns
- mixed the value from the related object
returns table and columns metadata
- Returns
- array assoc array with columns, primary keys and name of table
static getter_setter_map |
( |
| ) |
|
|
staticprotected |
assoc array for mapping get/set Methods
- Returns
- array
returns value of a column
- Exceptions
-
InvalidArgumentException | if column could not be found |
BadMethodCallException | if getter for additional field could not be found |
- Parameters
-
- Returns
- null|string|SimpleORMapCollection
returns sql clause with current table and pk
- Exceptions
-
UnexpectedValueException | if the primary key is incomplete |
- Returns
- boolean|array<string>
static has_and_belongs_to_many |
( |
| ) |
|
|
staticprotected |
n:m relations
- Returns
- array
1:n relation
- Returns
- array
1:1 relation
- Returns
- array
hasAutoIncrementColumn |
( |
| ) |
|
returns true, if table has an auto_increment column
- Returns
- boolean
multi-language fields name => boolean
- Returns
- array
generate SimpleORMap object structure from assoc array if given array contains data of related objects in sub-arrays they are also generated. Existing records are updated, new records are created (but changes are not yet stored)
- Parameters
-
- Returns
- static
init internal content arrays with nulls or defaults
- Exceptions
-
UnexpectedValueException | if there is an unmatched alias |
- Returns
- void
initRelation |
( |
|
$relation | ) |
|
intitalize a relationship and get related record(s)
- Parameters
-
string | $relation | name of relation |
- Exceptions
-
InvalidArgumentException | if the relation does not exists |
- Returns
- void
isAdditionalField |
( |
|
$field | ) |
|
check if given column is additional
- Parameters
-
- Returns
- boolean
check if given column is an alias
- Parameters
-
- Returns
- boolean
check if object was deleted
- Returns
- boolean
checks if at least one field was modified since last restore
- Returns
- boolean
check if given column exists in table
- Parameters
-
- Returns
- boolean
checks if given field was modified since last restore
- Parameters
-
- Returns
- boolean
check if given column is a multi-language field
- Parameters
-
- Returns
- boolean
check if object exists in database
- Returns
- boolean
check if given relation exists in this class
- Parameters
-
- Returns
- boolean
contains an array of all used identifiers for fields (db columns + aliased columns + additional columns + relations)
- Returns
- array
static notification_map |
( |
| ) |
|
|
staticprotected |
assoc array used to map SORM callback to NotificationCenter keys are SORM callbacks, values notifications eg. 'after_create' => 'FooDidCreate'
- Returns
- array
ArrayAccess: Check whether the given offset exists.
- Parameters
-
- Returns
- bool
ArrayAccess: Get the value at the given offset.
- Exceptions
-
InvalidArgumentException | if column could not be found |
BadMethodCallException | if getter for additional field could not be found |
- Parameters
-
string | $offset | the column or additional field |
- Returns
- null|string|SimpleORMapCollection
offsetSet |
( |
|
$offset, |
|
|
|
$value |
|
) |
| |
ArrayAccess: Set the value at the given offset.
- Exceptions
-
InvalidArgumentException | if column could not be found |
BadMethodCallException | if setter for additional field could not be found |
- Parameters
-
string | $offset | |
mixed | $value | |
- Returns
- void
ArrayAccess: unset the value at the given offset (not applicable)
- Parameters
-
- Returns
- void
parseRelationOptions |
( |
|
$type, |
|
|
|
$name, |
|
|
|
$options |
|
) |
| |
|
protected |
try to determine all needed options for a relationship from configured options
- Parameters
-
string | $type | |
string | $name | |
array | $options | |
- Exceptions
-
Exception | if options for thru_table could not be determined |
- Returns
- array
primary key columns
- Returns
- array
static registerCallback |
( |
|
$types, |
|
|
|
$cb |
|
) |
| |
|
staticprotected |
register given callback for one or many possible callback types callback param could be a closure or method name of current class
- Parameters
-
string | array | $types | types to register callback for |
callable | $cb | callback |
- Exceptions
-
InvalidArgumentException | if the callback type is not known |
- Returns
- number of registered callbacks
static registered_callbacks |
( |
| ) |
|
|
staticprotected |
callbacks
- Returns
- array<string, array<string|Closure>>
resetRelation |
( |
|
$relation | ) |
|
clear data for a relationship
- Parameters
-
string | $relation | name of relation |
- Exceptions
-
InvalidArgumentException | if teh relation does not exists |
- Returns
- void
restore entry from database
- Returns
- boolean
reverts value of given field to last restored value
- Parameters
-
- Returns
- mixed the restored value
static serialized_fields |
( |
| ) |
|
|
staticprotected |
list of columns to deserialize
- Returns
- array key is name of column, value is name of ArrayObject class
setData |
( |
|
$data, |
|
|
|
$reset = false |
|
) |
| |
set multiple column values if second param is set, existing data in object will be discarded and dirty state is cleared, else new data overrides old data
- Parameters
-
?iterable | $data assoc array |
?boolean | $reset existing data in object will be discarded |
- Returns
- int|bool number of columns changed
setI18nValue |
( |
|
$field, |
|
|
|
$value |
|
) |
| |
|
protected |
default setter used to proxy I18N fields with I18NString
- Parameters
-
string | $field | column name |
mixed | $value | value |
- Returns
- mixed
set primary key for entry, combined keys must be passed as array
- Parameters
-
int | string | array | $id | primary key |
- Exceptions
-
InvalidArgumentException | if given key is not complete |
- Returns
- boolean
set object to new state
- Parameters
-
- Returns
- boolean
setSerializedValue |
( |
|
$field, |
|
|
|
$value |
|
) |
| |
|
protected |
default setter used to proxy serialized fields with ArrayObjects
- Parameters
-
string | $field | column name |
mixed | $value | value |
- Returns
- mixed
setValue |
( |
|
$field, |
|
|
|
$value |
|
) |
| |
sets value of a column
- Exceptions
-
InvalidArgumentException | if column could not be found |
BadMethodCallException | if setter for additional field could not be found |
- Parameters
-
- Returns
- string
store entry in database
- Exceptions
-
UnexpectedValueException | if there are forbidden NULL values |
- Returns
- number|boolean
storeRelations |
( |
|
$only_these = null | ) |
|
|
protected |
sends a store message to all initialized related objects if a relation has a callback for 'on_store' configured, the callback is instead invoked
- Parameters
-
null | array | string | $only_these | |
- Returns
- int|false number addition of all return values, false if none was called
static tableScheme |
( |
|
$db_table | ) |
|
|
static |
fetch table metadata from db or from local cache
- Parameters
-
- Returns
- bool true if metadata could be fetched
toArray |
( |
|
$only_these_fields = null | ) |
|
returns data of table row as assoc array pass array of fieldnames or ws separated string to limit fields
- Parameters
-
null | array | string | $only_these_fields | limit returned fields |
- Returns
- array
toArrayRecursive |
( |
|
$only_these_fields = null | ) |
|
returns data of table row as assoc array including related records with a 'has*' relationship recurses one level without param
$only_these_fields limits output for relationships in this way: $only_these_fields = array('field_1', 'field_2', 'relation1', 'relation2' => array('rel2_f1', 'rel2_f2', 'rel2_rel11' => array( rel2_rel1_f1) ) ) Here all fields of relation1 will be returned.
- Parameters
-
null | array | string | $only_these_fields | limit returned fields |
- Returns
- array
static toObject |
( |
|
$id_or_object | ) |
|
|
static |
returns object of given class for given id or null the param could be a string, an assoc array containing primary key field or an already matching object. In all these cases an object is returned
- Parameters
-
string | static | array | $id_or_object | id as string, object or assoc array |
- Returns
- static
toRawArray |
( |
|
$only_these_fields = null | ) |
|
Returns data of table row as assoc array with raw contents like they are in the database. Pass array of fieldnames or ws separated string to limit fields.
- Parameters
-
null | array | string | $only_these_fields | |
- Returns
- array
set chdate column to current timestamp
- Returns
- boolean
static unregisterCallback |
( |
|
$types, |
|
|
|
$cb |
|
) |
| |
|
staticprotected |
unregister given callback for one or many possible callback types
- Parameters
-
string | array | $types | types to unregister callback for |
mixed | $cb | |
- Exceptions
-
InvalidArgumentException | if the callback type is not known |
- Returns
- number of unregistered callbacks
array $additional_data = [] |
|
protected |
assoc array for storing values for additional fields
configuration data for subclasses
- See Also
- self::configure()
boolean $is_deleted = false |
|
protected |
bool $performs_batch_operation = false |
|
staticprotected |
indicator for batch operations in findEachBySQL
stores instantiated related objects
array $reserved_slots = ['value','newid','iterator','tablemetadata', 'relationvalue','wherequery','relationoptions','data','new','id'] |
|
staticprotected |
reserved indentifiers, fields with those names must not have an explicit getXXX() method
Defines _
as character used when joining composite primary keys.
The documentation for this class was generated from the following file: