Model Class Reference

Public Member Functions | |
| _clearCache ($type=null) | |
| _clearCache ($type=null) | |
| _deleteHasMany ($id, $cascade) | |
| _deleteHasMany ($id, $cascade) | |
| _deleteHasOne ($id, $cascade) | |
| _deleteHasOne ($id, $cascade) | |
| _deleteMulti ($id) | |
| _deleteMulti ($id) | |
| afterDelete () | |
| afterDelete () | |
| afterFind ($results) | |
| afterFind ($results) | |
| afterSave () | |
| afterSave () | |
| beforeDelete () | |
| beforeDelete () | |
| beforeFind (&$queryData) | |
| beforeFind (&$queryData) | |
| beforeSave () | |
| beforeSave () | |
| beforeValidate () | |
| beforeValidate () | |
| bindModel ($params) | |
| bindModel ($params) | |
| create () | |
| create () | |
| del ($id=null, $cascade=true) | |
| del ($id=null, $cascade=true) | |
| delete ($id=null, $cascade=true) | |
| delete ($id=null, $cascade=true) | |
| escapeField ($field) | |
| escapeField ($field) | |
| execute ($data) | |
| execute ($data) | |
| exists () | |
| exists () | |
| field ($name, $conditions=null, $order=null) | |
| field ($name, $conditions=null, $order=null) | |
| find ($conditions=null, $fields=null, $order=null, $recursive=null) | |
| find ($conditions=null, $fields=null, $order=null, $recursive=null) | |
| findAll ($conditions=null, $fields=null, $order=null, $limit=null, $page=1, $recursive=null) | |
| findAll ($conditions=null, $fields=null, $order=null, $limit=null, $page=1, $recursive=null) | |
| findAllThreaded ($conditions=null, $fields=null, $sort=null) | |
| findAllThreaded ($conditions=null, $fields=null, $sort=null) | |
| findBySql ($sql) | |
| findBySql ($sql) | |
| findCount ($conditions=null, $recursive=0) | |
| findCount ($conditions=null, $recursive=0) | |
| findNeighbours ($conditions=null, $field, $value) | |
| findNeighbours ($conditions=null, $field, $value) | |
| generateList ($conditions=null, $order=null, $limit=null, $keyPath=null, $valuePath=null) | |
| generateList ($conditions=null, $order=null, $limit=null, $keyPath=null, $valuePath=null) | |
| getAffectedRows () | |
| getAffectedRows () | |
| getColumnType ($column) | |
| getColumnType ($column) | |
| getColumnTypes () | |
| getColumnTypes () | |
| getDisplayField () | |
| getDisplayField () | |
| getID ($list=0) | |
| getID ($list=0) | |
| getInsertID () | |
| getInsertID () | |
| getLastInsertID () | |
| getLastInsertID () | |
| getNumRows () | |
| getNumRows () | |
| hasAny ($conditions=null) | |
| hasAny ($conditions=null) | |
| hasField ($name) | |
| hasField ($name) | |
| invalidate ($field) | |
| invalidate ($field) | |
| invalidFields ($data=array()) | |
| invalidFields ($data=array()) | |
| isForeignKey ($field) | |
| isForeignKey ($field) | |
| loadInfo () | |
| loadInfo () | |
| onError () | |
| onError () | |
| query () | |
| query () | |
| read ($fields=null, $id=null) | |
| read ($fields=null, $id=null) | |
| remove ($id=null, $cascade=true) | |
| remove ($id=null, $cascade=true) | |
| save ($data=null, $validate=true, $fieldList=array()) | |
| save ($data=null, $validate=true, $fieldList=array()) | |
| saveField ($name, $value, $validate=false) | |
| saveField ($name, $value, $validate=false) | |
| set ($one, $two=null) | |
| set ($one, $two=null) | |
| setDataSource ($dataSource=null) | |
| setDataSource ($dataSource=null) | |
| setId ($id) | |
| setId ($id) | |
| setInsertID ($id) | |
| setInsertID ($id) | |
| setSource ($tableName) | |
| setSource ($tableName) | |
| unbindModel ($params) | |
| unbindModel ($params) | |
| validates ($data=array()) | |
| validates ($data=array()) | |
Public Attributes | |
| $_tableInfo = null | |
| $alias = null | |
| $belongsTo = array() | |
| $cacheQueries = true | |
| $cacheSources = true | |
| $currentModel = null | |
| $data = array() | |
| $displayField = null | |
| $hasAndBelongsToMany = array() | |
| $hasMany = array() | |
| $hasOne = array() | |
| $id = false | |
| $keyToTable = array() | |
| $logTransactions = false | |
| $modelToTable = array() | |
| $name = null | |
| $primaryKey = null | |
| $recursive = 1 | |
| $table = false | |
| $tablePrefix = null | |
| $tableToModel = array() | |
| $transactional = false | |
| $useDbConfig = 'default' | |
| $useTable = null | |
| $validate = array() | |
| $validationErrors = array() | |
| $whitelist = array() | |
Detailed Description
Definition at line 45 of file model_php4.php.
Member Function Documentation
| Model::_clearCache | ( | $ | type = null |
) |
Private method. Clears cache for this model
- Parameters:
-
string $type If null this deletes cached views if CACHE_CHECK is true Will be used to allow deleting query cache also
- Returns:
- boolean true on delete protected
Definition at line 1676 of file model_php5.php.
References Inflector::pluralize().
| Model::_clearCache | ( | $ | type = null |
) |
Private method. Clears cache for this model
- Parameters:
-
string $type If null this deletes cached views if CACHE_CHECK is true Will be used to allow deleting query cache also
- Returns:
- boolean true on delete protected
Definition at line 1675 of file model_php4.php.
References Inflector::pluralize().
| Model::_deleteHasMany | ( | $ | id, | |
| $ | cascade | |||
| ) |
Cascades model deletes to hasMany relationships.
- Parameters:
-
string $id
- Returns:
- null protected
Definition at line 1038 of file model_php5.php.
References $data.
| Model::_deleteHasMany | ( | $ | id, | |
| $ | cascade | |||
| ) |
Cascades model deletes to hasMany relationships.
- Parameters:
-
string $id
- Returns:
- null protected
Definition at line 1037 of file model_php4.php.
References $data.
| Model::_deleteHasOne | ( | $ | id, | |
| $ | cascade | |||
| ) |
Cascades model deletes to hasOne relationships.
- Parameters:
-
string $id
- Returns:
- null protected
Definition at line 1068 of file model_php5.php.
References $data.
| Model::_deleteHasOne | ( | $ | id, | |
| $ | cascade | |||
| ) |
Cascades model deletes to hasOne relationships.
- Parameters:
-
string $id
- Returns:
- null protected
Definition at line 1067 of file model_php4.php.
References $data.
| Model::_deleteMulti | ( | $ | id | ) |
Cascades model deletes to HABTM join keys.
- Parameters:
-
string $id
- Returns:
- null protected
Definition at line 1098 of file model_php5.php.
References $data, and ConnectionManager::getDataSource().
| Model::_deleteMulti | ( | $ | id | ) |
Cascades model deletes to HABTM join keys.
- Parameters:
-
string $id
- Returns:
- null protected
Definition at line 1097 of file model_php4.php.
References $data, and ConnectionManager::getDataSource().
| Model::afterDelete | ( | ) |
| Model::afterDelete | ( | ) |
| Model::afterFind | ( | $ | results | ) |
After find callback. Can be used to modify any results returned by find and findAll.
- Parameters:
-
mixed $results The results of the find operation
- Returns:
- mixed Result of the find operation public
Definition at line 1613 of file model_php5.php.
| Model::afterFind | ( | $ | results | ) |
After find callback. Can be used to modify any results returned by find and findAll.
- Parameters:
-
mixed $results The results of the find operation
- Returns:
- mixed Result of the find operation public
Definition at line 1612 of file model_php4.php.
| Model::afterSave | ( | ) |
| Model::afterSave | ( | ) |
| Model::beforeDelete | ( | ) |
Before delete callback
- Returns:
- boolean True if the operation should continue, false if it should abort public
Definition at line 1640 of file model_php5.php.
| Model::beforeDelete | ( | ) |
Before delete callback
- Returns:
- boolean True if the operation should continue, false if it should abort public
Definition at line 1639 of file model_php4.php.
| Model::beforeFind | ( | &$ | queryData | ) |
Before find callback
- Parameters:
-
array $queryData Data used to execute this query, i.e. conditions, order, etc.
- Returns:
- boolean True if the operation should continue, false if it should abort public
Definition at line 1603 of file model_php5.php.
| Model::beforeFind | ( | &$ | queryData | ) |
Before find callback
- Parameters:
-
array $queryData Data used to execute this query, i.e. conditions, order, etc.
- Returns:
- boolean True if the operation should continue, false if it should abort public
Definition at line 1602 of file model_php4.php.
| Model::beforeSave | ( | ) |
Before save callback
- Returns:
- boolean True if the operation should continue, false if it should abort public
Definition at line 1622 of file model_php5.php.
| Model::beforeSave | ( | ) |
Before save callback
- Returns:
- boolean True if the operation should continue, false if it should abort public
Definition at line 1621 of file model_php4.php.
| Model::beforeValidate | ( | ) |
| Model::beforeValidate | ( | ) |
| Model::bindModel | ( | $ | params | ) |
Bind model associations on the fly.
- Parameters:
-
array $params
- Returns:
- true public
Definition at line 371 of file model_php5.php.
| Model::bindModel | ( | $ | params | ) |
Bind model associations on the fly.
- Parameters:
-
array $params
- Returns:
- true public
Definition at line 378 of file model_php4.php.
| Model::create | ( | ) |
Initializes the model for writing a new record.
- Returns:
- boolean True public
Definition at line 692 of file model_php5.php.
| Model::create | ( | ) |
Initializes the model for writing a new record.
- Returns:
- boolean True public
Definition at line 699 of file model_php4.php.
| Model::del | ( | $ | id = null, |
|
| $ | cascade = true | |||
| ) |
Removes record for given id. If no id is given, the current id is used. Returns true on success.
- Parameters:
-
mixed $id Id of record to delete
- Returns:
- boolean True on success public
Definition at line 997 of file model_php5.php.
References ConnectionManager::getDataSource().
| Model::del | ( | $ | id = null, |
|
| $ | cascade = true | |||
| ) |
Removes record for given id. If no id is given, the current id is used. Returns true on success.
- Parameters:
-
mixed $id Id of record to delete
- Returns:
- boolean True on success public
Definition at line 996 of file model_php4.php.
References ConnectionManager::getDataSource().
| Model::delete | ( | $ | id = null, |
|
| $ | cascade = true | |||
| ) |
Alias for del()
- Parameters:
-
mixed $id Id of record to delete
- Returns:
- boolean True on success public
Definition at line 1028 of file model_php5.php.
| Model::delete | ( | $ | id = null, |
|
| $ | cascade = true | |||
| ) |
Alias for del()
- Parameters:
-
mixed $id Id of record to delete
- Returns:
- boolean True on success public
Definition at line 1027 of file model_php4.php.
| Model::escapeField | ( | $ | field | ) |
Escapes the field name and prepends the model name. Escaping will be done according to the current database driver's rules.
- Parameters:
-
unknown_type $field
- Returns:
- string The name of the escaped field for this Model (i.e. id becomes `Post`.`id`). public
Definition at line 1498 of file model_php5.php.
References ConnectionManager::getDataSource().
| Model::escapeField | ( | $ | field | ) |
Escapes the field name and prepends the model name. Escaping will be done according to the current database driver's rules.
- Parameters:
-
unknown_type $field
- Returns:
- string The name of the escaped field for this Model (i.e. id becomes `Post`.`id`). public
Definition at line 1497 of file model_php4.php.
References ConnectionManager::getDataSource().
| Model::execute | ( | $ | data | ) |
Runs a direct query against the bound DataSource, and returns the result.
- Parameters:
-
string $data Query data
- Returns:
- array public
Definition at line 1232 of file model_php5.php.
References $data, and ConnectionManager::getDataSource().
| Model::execute | ( | $ | data | ) |
Runs a direct query against the bound DataSource, and returns the result.
- Parameters:
-
string $data Query data
- Returns:
- array public
Definition at line 1231 of file model_php4.php.
References $data, and ConnectionManager::getDataSource().
| Model::exists | ( | ) |
Returns true if a record with set id exists.
- Returns:
- boolean True if such a record exists public
Definition at line 1110 of file model_php5.php.
References ConnectionManager::getDataSource().
| Model::exists | ( | ) |
Returns true if a record with set id exists.
- Returns:
- boolean True if such a record exists public
Definition at line 1109 of file model_php4.php.
References ConnectionManager::getDataSource().
| Model::field | ( | $ | name, | |
| $ | conditions = null, |
|||
| $ | order = null | |||
| ) |
Returns contents of a field in a query matching given conditions.
- Parameters:
-
string $name Name of field to get array $conditions SQL conditions (defaults to NULL) string $order SQL ORDER BY fragment
- Returns:
- field contents public
Definition at line 749 of file model_php5.php.
References $data.
| Model::field | ( | $ | name, | |
| $ | conditions = null, |
|||
| $ | order = null | |||
| ) |
Returns contents of a field in a query matching given conditions.
- Parameters:
-
string $name Name of field to get array $conditions SQL conditions (defaults to NULL) string $order SQL ORDER BY fragment
- Returns:
- field contents public
Definition at line 756 of file model_php4.php.
References $data.
| Model::find | ( | $ | conditions = null, |
|
| $ | fields = null, |
|||
| $ | order = null, |
|||
| $ | recursive = null | |||
| ) |
Return a single row as a resultset array. By using the $recursive parameter, the call can access further "levels of association" than the ones this model is directly associated to.
- Parameters:
-
array $conditions SQL conditions array mixed $fields Either a single string of a field name, or an array of field names string $order SQL ORDER BY conditions (e.g. "price DESC" or "name ASC") int $recursive The number of levels deep to fetch associated records
- Returns:
- array Array of records public
Definition at line 1145 of file model_php5.php.
References $data.
| Model::find | ( | $ | conditions = null, |
|
| $ | fields = null, |
|||
| $ | order = null, |
|||
| $ | recursive = null | |||
| ) |
Return a single row as a resultset array. By using the $recursive parameter, the call can access further "levels of association" than the ones this model is directly associated to.
- Parameters:
-
array $conditions SQL conditions array mixed $fields Either a single string of a field name, or an array of field names string $order SQL ORDER BY conditions (e.g. "price DESC" or "name ASC") int $recursive The number of levels deep to fetch associated records
- Returns:
- array Array of records public
Definition at line 1144 of file model_php4.php.
References $data.
Referenced by AclNode::create(), AclNode::delete(), AclNode::getChildren(), AclNode::getPath(), Cache::has(), AclNode::id(), Cache::restore(), and AclNode::setParent().
| Model::findAll | ( | $ | conditions = null, |
|
| $ | fields = null, |
|||
| $ | order = null, |
|||
| $ | limit = null, |
|||
| $ | page = 1, |
|||
| $ | recursive = null | |||
| ) |
Returns a resultset array with specified fields from database matching given conditions. By using the $recursive parameter, the call can access further "levels of association" than the ones this model is directly associated to.
- Parameters:
-
mixed $conditions SQL conditions as a string or as an array('field' =>'value',...) mixed $fields Either a single string of a field name, or an array of field names string $order SQL ORDER BY conditions (e.g. "price DESC" or "name ASC") int $limit SQL LIMIT clause, for calculating items per page. int $page Page number, for accessing paged data int $recursive The number of levels deep to fetch associated records
- Returns:
- array Array of records public
Definition at line 1168 of file model_php5.php.
References ConnectionManager::getDataSource().
| Model::findAll | ( | $ | conditions = null, |
|
| $ | fields = null, |
|||
| $ | order = null, |
|||
| $ | limit = null, |
|||
| $ | page = 1, |
|||
| $ | recursive = null | |||
| ) |
Returns a resultset array with specified fields from database matching given conditions. By using the $recursive parameter, the call can access further "levels of association" than the ones this model is directly associated to.
- Parameters:
-
mixed $conditions SQL conditions as a string or as an array('field' =>'value',...) mixed $fields Either a single string of a field name, or an array of field names string $order SQL ORDER BY conditions (e.g. "price DESC" or "name ASC") int $limit SQL LIMIT clause, for calculating items per page. int $page Page number, for accessing paged data int $recursive The number of levels deep to fetch associated records
- Returns:
- array Array of records public
Definition at line 1167 of file model_php4.php.
References ConnectionManager::getDataSource().
Referenced by AclNode::delete(), findAllThreaded(), findNeighbours(), AclNode::getChildren(), and AclNode::getPath().
| Model::findAllThreaded | ( | $ | conditions = null, |
|
| $ | fields = null, |
|||
| $ | sort = null | |||
| ) |
Special findAll variation for tables joined to themselves. The table needs the fields id and parent_id to work.
- Parameters:
-
array $conditions Conditions for the findAll() call array $fields Fields for the findAll() call string $sort SQL ORDER BY statement
- Returns:
- array public
Definition at line 1283 of file model_php5.php.
References findAll().
| Model::findAllThreaded | ( | $ | conditions = null, |
|
| $ | fields = null, |
|||
| $ | sort = null | |||
| ) |
Special findAll variation for tables joined to themselves. The table needs the fields id and parent_id to work.
- Parameters:
-
array $conditions Conditions for the findAll() call array $fields Fields for the findAll() call string $sort SQL ORDER BY statement
- Returns:
- array public
Definition at line 1282 of file model_php4.php.
References findAll().
| Model::findBySql | ( | $ | sql | ) |
| Model::findBySql | ( | $ | sql | ) |
| Model::findCount | ( | $ | conditions = null, |
|
| $ | recursive = 0 | |||
| ) |
Returns number of rows matching given SQL condition.
- Parameters:
-
array $conditions SQL conditions array for findAll int $recursize The number of levels deep to fetch associated records
- Returns:
- int Number of matching rows
- See also:
- Model::findAll public
Definition at line 1259 of file model_php5.php.
References $data, and ConnectionManager::getDataSource().
| Model::findCount | ( | $ | conditions = null, |
|
| $ | recursive = 0 | |||
| ) |
Returns number of rows matching given SQL condition.
- Parameters:
-
array $conditions SQL conditions array for findAll int $recursize The number of levels deep to fetch associated records
- Returns:
- int Number of matching rows
- See also:
- Model::findAll public
Definition at line 1258 of file model_php4.php.
References $data, and ConnectionManager::getDataSource().
| Model::findNeighbours | ( | $ | conditions = null, |
|
| $ | field, | |||
| $ | value | |||
| ) |
Returns an array with keys "prev" and "next" that holds the id's of neighbouring data, which is useful when creating paged lists.
- Parameters:
-
string $conditions SQL conditions for matching rows string $field Field name (parameter for findAll) unknown_type $value
- Returns:
- array Array with keys "prev" and "next" that holds the id's public
Definition at line 1325 of file model_php5.php.
References findAll(), and ConnectionManager::getDataSource().
| Model::findNeighbours | ( | $ | conditions = null, |
|
| $ | field, | |||
| $ | value | |||
| ) |
Returns an array with keys "prev" and "next" that holds the id's of neighbouring data, which is useful when creating paged lists.
- Parameters:
-
string $conditions SQL conditions for matching rows string $field Field name (parameter for findAll) unknown_type $value
- Returns:
- array Array with keys "prev" and "next" that holds the id's public
Definition at line 1324 of file model_php4.php.
References findAll(), and ConnectionManager::getDataSource().
| Model::generateList | ( | $ | conditions = null, |
|
| $ | order = null, |
|||
| $ | limit = null, |
|||
| $ | keyPath = null, |
|||
| $ | valuePath = null | |||
| ) |
Returns a resultset array with specified fields from database matching given conditions. Method can be used to generate option lists for SELECT elements.
- Parameters:
-
mixed $conditions SQL conditions as a string or as an array('field' =>'value',...) string $order SQL ORDER BY conditions (e.g. "price DESC" or "name ASC") int $limit SQL LIMIT clause, for calculating items per page string $keyPath A string path to the key, i.e. "{n}.Post.id" string $valuePath A string path to the value, i.e. "{n}.Post.title"
- Returns:
- array An associative array of records, where the id is the key, and the display field is the value public
Definition at line 1456 of file model_php5.php.
References Set::extract().
| Model::generateList | ( | $ | conditions = null, |
|
| $ | order = null, |
|||
| $ | limit = null, |
|||
| $ | keyPath = null, |
|||
| $ | valuePath = null | |||
| ) |
Returns a resultset array with specified fields from database matching given conditions. Method can be used to generate option lists for SELECT elements.
- Parameters:
-
mixed $conditions SQL conditions as a string or as an array('field' =>'value',...) string $order SQL ORDER BY conditions (e.g. "price DESC" or "name ASC") int $limit SQL LIMIT clause, for calculating items per page string $keyPath A string path to the key, i.e. "{n}.Post.id" string $valuePath A string path to the value, i.e. "{n}.Post.title"
- Returns:
- array An associative array of records, where the id is the key, and the display field is the value public
Definition at line 1455 of file model_php4.php.
References Set::extract().
| Model::getAffectedRows | ( | ) |
Returns the number of rows affected by the last query
- Returns:
- int public
Definition at line 1571 of file model_php5.php.
References ConnectionManager::getDataSource().
| Model::getAffectedRows | ( | ) |
Returns the number of rows affected by the last query
- Returns:
- int public
Definition at line 1570 of file model_php4.php.
References ConnectionManager::getDataSource().
| Model::getColumnType | ( | $ | column | ) |
Returns the column type of a column in the model
- Parameters:
-
string $column The name of the model column
- Returns:
- string public
Definition at line 648 of file model_php5.php.
References loadInfo().
| Model::getColumnType | ( | $ | column | ) |
Returns the column type of a column in the model
- Parameters:
-
string $column The name of the model column
- Returns:
- string public
Definition at line 655 of file model_php4.php.
References loadInfo().
| Model::getColumnTypes | ( | ) |
Returns an associative array of field names and column types.
- Returns:
- array public
Definition at line 630 of file model_php5.php.
References ConnectionManager::getDataSource(), and loadInfo().
| Model::getColumnTypes | ( | ) |
Returns an associative array of field names and column types.
- Returns:
- array public
Definition at line 637 of file model_php4.php.
References ConnectionManager::getDataSource(), and loadInfo().
| Model::getDisplayField | ( | ) |
Gets the display field for this model
- Returns:
- string The name of the display field for this Model (i.e. 'name', 'title'). public
Definition at line 1441 of file model_php5.php.
| Model::getDisplayField | ( | ) |
Gets the display field for this model
- Returns:
- string The name of the display field for this Model (i.e. 'name', 'title'). public
Definition at line 1440 of file model_php4.php.
| Model::getID | ( | $ | list = 0 |
) |
Returns the current record's ID
- Parameters:
-
unknown_type $list
- Returns:
- mixed The ID of the current record public
Definition at line 1509 of file model_php5.php.
| Model::getID | ( | $ | list = 0 |
) |
Returns the current record's ID
- Parameters:
-
unknown_type $list
- Returns:
- mixed The ID of the current record public
Definition at line 1508 of file model_php4.php.
| Model::getInsertID | ( | ) |
Returns the ID of the last record this Model inserted
- Returns:
- mixed public
Definition at line 1543 of file model_php5.php.
| Model::getInsertID | ( | ) |
Returns the ID of the last record this Model inserted
- Returns:
- mixed public
Definition at line 1542 of file model_php4.php.
| Model::getLastInsertID | ( | ) |
Returns the ID of the last record this Model inserted
- Returns:
- mixed public
Definition at line 1534 of file model_php5.php.
| Model::getLastInsertID | ( | ) |