|
| static | expireTableScheme () |
| |
| static | find ($id) |
| |
| static | exists ($id) |
| |
| static | countBySql ($sql=1, $params=array()) |
| |
| static | create ($data) |
| |
| static | build ($data, $is_new=true) |
| |
| static | buildExisting ($data) |
| |
| static | import ($data) |
| |
| static | findBySQL ($sql, $params=array()) |
| |
| static | findByObject (SimpleORMap $object) |
| |
| static | findOneBySQL ($where, $params=array()) |
| |
| static | findThru ($foreign_key_value, $options) |
| |
| static | findEachBySQL ($callable, $sql, $params=array()) |
| |
| static | findMany ($pks=array(), $order='', $order_params=array()) |
| |
| static | findEachMany ($callable, $pks=array(), $order='', $order_params=array()) |
| |
| static | findAndMapBySQL ($callable, $where, $params=array()) |
| |
| static | findAndMapMany ($callable, $pks=array(), $order='', $order_params=array()) |
| |
| static | deleteBySQL ($where, $params=array()) |
| |
| static | toObject ($id_or_object) |
| |
| static | __callStatic ($name, $arguments) |
| |
◆ __construct()
| __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
-
| mixed | $id | primary key of table |
◆ __callStatic()
| static __callStatic |
( |
|
$name, |
|
|
|
$arguments |
|
) |
| |
|
static |
interceptor for static findByColumn / findEachByColumn magic
- Parameters
-
| string | $name | |
| array | $arguments | |
- Exceptions
-
- Returns
- mixed
◆ __clone()
clean up references after cloning
◆ __get()
magic method for dynamic properties
◆ __isset()
magic method for dynamic properties
◆ __set()
magic method for dynamic properties
◆ _getAdditionalValue()
| _getAdditionalValue |
( |
|
$field | ) |
|
|
protected |
- Parameters
-
- Returns
- multitype:
◆ _getAdditionalValueFromRelation()
| _getAdditionalValueFromRelation |
( |
|
$field | ) |
|
|
protected |
retrieves an additional field value from relation
- Parameters
-
- Returns
- multitype:
◆ _getId()
returns internal used id value (multiple keys concatenated with _)
◆ _setAdditionalValue()
| _setAdditionalValue |
( |
|
$field, |
|
|
|
$value |
|
) |
| |
|
protected |
- Parameters
-
- Returns
- multitype:
◆ _setAdditionalValueFromRelation()
| _setAdditionalValueFromRelation |
( |
|
$field, |
|
|
|
$value |
|
) |
| |
|
protected |
sets additional value in field imported from relation
- Parameters
-
- Returns
- multitype:
◆ _setId()
| _setId |
( |
|
$field, |
|
|
|
$value |
|
) |
| |
|
protected |
sets internal used id value (multiple keys concatenated with _)
◆ applyCallbacks()
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
◆ build()
| static build |
( |
|
$data, |
|
|
|
$is_new = true |
|
) |
| |
|
static |
build object with given data
- Parameters
-
| array | assoc array of record |
| bool | set object to new state |
- Returns
- SimpleORMap
◆ buildExisting()
| static buildExisting |
( |
|
$data | ) |
|
|
static |
◆ cbAutoIncrementColumn()
| cbAutoIncrementColumn |
( |
|
$type | ) |
|
|
protected |
default callback for tables with auto_increment primary key
- Parameters
-
- Returns
- boolean
◆ cbAutoKeyCreation()
default callback for tables without auto_increment
◆ cbNotificationMapper()
| cbNotificationMapper |
( |
|
$cb_type | ) |
|
|
protected |
default callback used to map specific callbacks to NotificationCenter
- Parameters
-
| string | $cb_type | callback type |
- Returns
- boolean
◆ configure()
| static configure |
( |
|
$config = array() | ) |
|
|
staticprotected |
set configuration data from subclass
- Parameters
-
| array | $config | configuration data |
- Returns
- void
◆ count()
◆ countBySql()
| static countBySql |
( |
|
$sql = 1, |
|
|
|
$params = array() |
|
) |
| |
|
static |
returns number of records
- Parameters
-
| string | sql clause to use on the right side of WHERE |
| array | params for query |
- Returns
- number
◆ create()
creates new record with given data in db returns the new object or null
- Parameters
-
| array | assoc array of record |
- Returns
- SimpleORMap
◆ delete()
delete entry from database the object is cleared, but is not(!) turned to new state
- Returns
- int number of deleted rows
◆ deleteBySQL()
| static deleteBySQL |
( |
|
$where, |
|
|
|
$params = array() |
|
) |
| |
|
static |
deletes objects specified by sql clause
- Parameters
-
| string | sql clause to use on the right side of WHERE |
| array | parameters for query |
- Returns
- number
◆ deleteRelations()
sends a delete message to all related objects if a relation has a callback for 'on_delete' configured, the callback is invoked instead
- Returns
- number addition of all return values, false if none was called
◆ exists()
returns true if given key exists in db
- Parameters
-
- Returns
- boolean
◆ expireTableScheme()
| static expireTableScheme |
( |
| ) |
|
|
static |
force reload of cached table metadata
◆ find()
returns new instance for given key when found in db, else null
- Parameters
-
- Returns
- SimpleORMap|NULL
◆ findAndMapBySQL()
| static findAndMapBySQL |
( |
|
$callable, |
|
|
|
$where, |
|
|
|
$params = array() |
|
) |
| |
|
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 clause of sql |
| array | sql statement parameters |
- Returns
- array return values of callback
◆ findAndMapMany()
| static findAndMapMany |
( |
|
$callable, |
|
|
|
$pks = array(), |
|
|
|
$order = '', |
|
|
|
$order_params = array() |
|
) |
| |
|
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 |
- Returns
- array return values of callback
◆ findByObject()
◆ findBySQL()
| static findBySQL |
( |
|
$sql, |
|
|
|
$params = array() |
|
) |
| |
|
static |
returns array of instances of given class filtered by given sql
- Parameters
-
| string | sql clause to use on the right side of WHERE |
| array | parameters for query |
- Returns
- array array of "self" objects
◆ findEachBySQL()
| static findEachBySQL |
( |
|
$callable, |
|
|
|
$sql, |
|
|
|
$params = array() |
|
) |
| |
|
static |
passes objects for given sql through given callback
- Parameters
-
| callable | $callable | callback which gets the current record as param |
| string | where clause of sql |
| array | sql statement parameters |
- Returns
- integer number of found records
◆ findEachMany()
| static findEachMany |
( |
|
$callable, |
|
|
|
$pks = array(), |
|
|
|
$order = '', |
|
|
|
$order_params = array() |
|
) |
| |
|
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 |
- Returns
- integer number of found records
◆ findMany()
| static findMany |
( |
|
$pks = array(), |
|
|
|
$order = '', |
|
|
|
$order_params = array() |
|
) |
| |
|
static |
returns array of instances of given class for by given pks
- Parameters
-
| array | array og primary keys |
| string | order by clause |
- Returns
- array
◆ findOneBySQL()
| static findOneBySQL |
( |
|
$where, |
|
|
|
$params = array() |
|
) |
| |
|
static |
returns one instance of given class filtered by given sql only first row of query is used
- Parameters
-
| string | sql clause to use on the right side of WHERE |
| array | parameters for query |
- Returns
- SimpleORMap|NULL
◆ findThru()
| 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 | value of foreign key to find related records |
| array | relation options from other side of relation |
- Returns
- array of "self" objects
◆ getId()
returns primary key, multiple keys as array
- Returns
- string|array current primary key, null if not set
◆ getIterator()
◆ getNewId()
create new unique pk as md5 hash if pk consists of multiple columns, false is returned
- Returns
- boolean|string
◆ getPristineValue()
| getPristineValue |
( |
|
$field | ) |
|
returns unmodified value of given field
- Parameters
-
- Exceptions
-
- Returns
- mixed
◆ getRelationOptions()
| 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()
| 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
◆ getTableMetadata()
returns table and columns metadata
- Returns
- array assoc array with columns, primary keys and name of table
◆ getTableScheme()
restore table metadata from db or cache
◆ getValue()
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
◆ getWhereQuery()
returns sql clause with current table and pk
- Returns
- boolean|string
◆ hasAutoIncrementColumn()
| hasAutoIncrementColumn |
( |
| ) |
|
returns true, if table has an auto_increment column
- Returns
- boolean
◆ haveData()
check if object is empty
- Returns
- bool true if at least one field is not null
◆ import()
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
- SimpleORMap
◆ initializeContent()
init internal content arrays with nulls
- Exceptions
-
| UnexpectedValueException | if there is an unmatched alias |
◆ initRelation()
| 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()
| isAdditionalField |
( |
|
$field | ) |
|
check if given column is additional
- Parameters
-
- Returns
- boolean
◆ isAliasField()
check if given column is an alias
- Parameters
-
- Returns
- boolean
◆ isDeleted()
check if object was deleted
- Returns
- boolean
◆ isDirty()
checks if at least one field was modified since last restore
- Returns
- boolean
◆ isField()
check if given column exists in table
- Parameters
-
- Returns
- boolean
◆ isFieldDirty()
checks if given field was modified since last restore
- Parameters
-
- Returns
- boolean
◆ isNew()
check if object exists in database
- Returns
- boolean
◆ offsetExists()
◆ offsetGet()
◆ offsetSet()
| offsetSet |
( |
|
$offset, |
|
|
|
$value |
|
) |
| |
◆ offsetUnset()
ArrayAccess: unset the value at the given offset (not applicable)
◆ parseRelationOptions()
| 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
◆ registerCallback()
| registerCallback |
( |
|
$types, |
|
|
|
$cb |
|
) |
| |
|
protected |
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 |
| mixed | $cb | callback |
- Exceptions
-
| InvalidArgumentException | if the callback type is not known |
- Returns
- number of registered callbacks
◆ resetRelation()
| resetRelation |
( |
|
$relation | ) |
|
clear data for a relationship
- Parameters
-
| string | $relation | name of relation |
- Exceptions
-
| InvalidArgumentException | if teh relation does not exists |
◆ restore()
restore entry from database
- Returns
- boolean
◆ revertValue()
reverts value of given field to last restored value
- Parameters
-
- Returns
- mixed the restored value
◆ setData()
| 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
-
| array | $data | assoc array |
| boolean | $reset | existing data in object will be discarded |
- Returns
- number of columns changed
◆ setId()
set primary key for entry, combined keys must be passed as array
- Parameters
-
- Exceptions
-
| InvalidArgumentException | if given key is not complete |
- Returns
- boolean
◆ setNew()
set object to new state
- Parameters
-
- Returns
- boolean
◆ setSerializedValue()
| setSerializedValue |
( |
|
$field, |
|
|
|
$value |
|
) |
| |
|
protected |
default setter used to proxy serialized fields with ArrayObjects
- Parameters
-
| string | $field | column name |
| string | $value | value |
◆ setValue()
| 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
-
| string | $field | |
| string | $value | |
- Returns
- string
◆ store()
store entry in database
- Exceptions
-
| UnexpectedValueException | if there are forbidden NULL values |
- Returns
- number|boolean
◆ storeRelations()
| 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
- Returns
- number addition of all return values, false if none was called
◆ tableScheme()
| static tableScheme |
( |
|
$db_table | ) |
|
|
staticprotected |
fetch table metadata from db or from local cache
- Parameters
-
- Returns
- bool true if metadata could be fetched
◆ toArray()
| 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
-
| mixed | $only_these_fields | limit returned fields |
- Returns
- array
◆ toArrayRecursive()
| 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
-
| mixed | $only_these_fields | limit returned fields |
- Returns
- array
◆ toObject()
| 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
-
| mixed | id as string, object or assoc array |
- Returns
- NULL|object
◆ triggerChdate()
set chdate column to current timestamp
- Returns
- boolean
◆ unregisterCallback()
| unregisterCallback |
( |
|
$types, |
|
|
|
$cb |
|
) |
| |
|
protected |
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
◆ $additional_data
| array $additional_data = array() |
|
protected |
assoc array for storing values for additional fields
◆ $additional_fields
| array $additional_fields = array() |
|
protected |
additional computed fields name => callable
◆ $alias_fields
| array $alias_fields = array() |
|
protected |
aliases for columns alias => column
◆ $belongs_to
| array $belongs_to = array() |
|
protected |
◆ $config
configuration data for subclasses
- See also
- self::configure()
◆ $content
◆ $content_db
| array $content_db = array() |
|
protected |
◆ $db_fields
◆ $db_table
◆ $default_values
| array $default_values = array() |
|
protected |
default values for columns
◆ $has_and_belongs_to_many
| array $has_and_belongs_to_many = array() |
|
protected |
◆ $has_many
| array $has_many = array() |
|
protected |
◆ $has_one
◆ $is_new
◆ $known_slots
| array $known_slots = array() |
|
protected |
contains an array of all used identifiers for fields (db columns + aliased columns + additional columns + relations)
◆ $notification_map
| array $notification_map = array() |
|
protected |
assoc array used to map SORM callback to NotificationCenter keys are SORM callbacks, values notifications eg. 'after_create' => 'FooDidCreate'
◆ $pk
◆ $registered_callbacks
| array $registered_callbacks |
|
protected |
Initial value: 'before_update' =>
array(),
'before_store' =>
array(),
'before_delete' =>
array(),
'before_initialize' =>
array(),
'after_create' =>
array(),
'after_update' =>
array(),
'after_store' =>
array(),
'after_delete' =>
array(),
'after_initialize' =>
array())
callbacks
◆ $relations
| array $relations = array() |
|
protected |
stores instantiated related objects
◆ $reserved_slots
| array $reserved_slots = array('value','newid','iterator','tablemetadata', 'relationvalue','wherequery','relationoptions','data','new','id') |
|
protected |
reserved indentifiers, fields with those names must not have an explicit getXXX() method
◆ $schemes
◆ $serialized_fields
| $serialized_fields = array() |
|
protected |
The documentation for this class was generated from the following file: