[ Index ] |
|
Code source de CakePHP 1.1.13.4450 |
[Code source] [Imprimer] [Statistiques]
Object-relational mapper. DBO-backed object data model, for mapping database tables to Cake objects.
Copyright: | Copyright 2005-2007, Cake Software Foundation, Inc. |
License: | http://www.opensource.org/licenses/mit-license.php The MIT License |
Version: | $Revision: 4450 $ |
Poids: | 1658 lignes (42 kb) |
Inclus ou requis: | 0 fois |
Référencé: | 0 fois |
Nécessite: | 0 fichiers |
Model:: (61 méthodes):
__construct()
__call()
bindModel()
unbindModel()
__createLinks()
__constructLinkedModel()
__generateAssociation()
setSource()
set()
loadInfo()
getColumnTypes()
getColumnType()
hasField()
create()
setId()
findBySql()
read()
field()
saveField()
save()
__saveMulti()
remove()
del()
delete()
_deleteHasMany()
_deleteHasOne()
_deleteMulti()
exists()
hasAny()
find()
findAll()
__resetAssociations()
execute()
findCount()
findAllThreaded()
__doThread()
findNeighbours()
query()
validates()
invalidFields()
invalidate()
isForeignKey()
getDisplayField()
generateList()
escapeField()
getID()
getLastInsertID()
getInsertID()
getNumRows()
getAffectedRows()
setDataSource()
beforeFind()
afterFind()
beforeSave()
afterSave()
beforeDelete()
afterDelete()
beforeValidate()
_clearCache()
__sleep()
__wakeup()
__construct($id = false, $table = null, $ds = null) X-Ref |
Constructor. Binds the Model's database table to the object. param: integer $id param: string $table Name of database table to use. param: DataSource $ds DataSource connection object. |
__call($method, $params, &$return) X-Ref |
PHP4 Only Handles custom method calls, like findBy<field> for DB models, and custom RPC calls for remote data sources param: unknown_type $method param: unknown_type $params param: unknown_type $return return: unknown |
bindModel($params) X-Ref |
Bind model associations on the fly. param: array $params return: true |
unbindModel($params) X-Ref |
Turn off associations on the fly. param: array $params return: true |
__createLinks() X-Ref |
Private helper method to create a set of associations. |
__constructLinkedModel($assoc, $className) X-Ref |
Private helper method to create associated models of given class. param: string $assoc param: string $className Class name param: string $type Type of assocation |
__generateAssociation($type) X-Ref |
Build array-based association from string. param: string $type "Belongs", "One", "Many", "ManyTo" |
setSource($tableName) X-Ref |
Sets a custom table for your controller class. Used by your controller to select a database table. param: string $tableName Name of the custom table |
set($one, $two = null) X-Ref |
This function does two things: 1) it scans the array $one for the primary key, and if that's found, it sets the current id to the value of $one[id]. For all other keys than 'id' the keys and values of $one are copied to the 'data' property of this object. 2) Returns an array with all of $one's keys and values. (Alternative indata: two strings, which are mangled to a one-item, two-dimensional array using $one for a key and $two as its value.) param: mixed $one Array or string of data param: string $two Value string for the alternative indata method return: array |
loadInfo() X-Ref |
Returns an array of table metadata (column names and types) from the database. return: array Array of table metadata |
getColumnTypes() X-Ref |
Returns an associative array of field names and column types. return: array |
getColumnType($column) X-Ref |
Returns the column type of a column in the model param: string $column The name of the model column return: string |
hasField($name) X-Ref |
Returns true if this Model has given field in its database table. param: string $name Name of field to look for return: boolean |
create() X-Ref |
Initializes the model for writing a new record. return: boolean True |
setId($id) X-Ref |
findBySql($sql) X-Ref |
Use query() instead. |
read($fields = null, $id = null) X-Ref |
Returns a list of fields from the database param: mixed $id The ID of the record to read param: mixed $fields String of single fieldname, or an array of fieldnames. return: array Array of database fields |
field($name, $conditions = null, $order = null) X-Ref |
Returns contents of a field in a query matching given conditions. param: string $name Name of field to get param: array $conditions SQL conditions (defaults to NULL) param: string $order SQL ORDER BY fragment return: field contents |
saveField($name, $value, $validate = false) X-Ref |
Saves a single field to the database. param: string $name Name of the table field param: mixed $value Value of the field param: boolean $validate Whether or not this model should validate before saving (defaults to false) return: boolean True on success save |
save($data = null, $validate = true, $fieldList = array() X-Ref |
Saves model data to the database. By default, validation occurs before save. param: array $data Data to save. param: boolean $validate If set, validation will be done before the save param: array $fieldList List of fields to allow to be written return: boolean success |
__saveMulti($joined, $id) X-Ref |
Saves model hasAndBelongsToMany data to the database. param: array $joined Data to save. param: string $id return: void |
remove($id = null, $cascade = true) X-Ref |
Synonym for del(). param: mixed $id return: boolean True on success |
del($id = null, $cascade = true) X-Ref |
Removes record for given id. If no id is given, the current id is used. Returns true on success. param: mixed $id Id of record to delete return: boolean True on success |
delete($id = null, $cascade = true) X-Ref |
Alias for del() param: mixed $id Id of record to delete return: boolean True on success |
_deleteHasMany($id, $cascade) X-Ref |
Cascades model deletes to hasMany relationships. param: string $id return: null |
_deleteHasOne($id, $cascade) X-Ref |
Cascades model deletes to hasOne relationships. param: string $id return: null |
_deleteMulti($id) X-Ref |
Cascades model deletes to HABTM join keys. param: string $id return: null |
exists() X-Ref |
Returns true if a record with set id exists. return: boolean True if such a record exists |
hasAny($conditions = null) X-Ref |
Returns true if a record that meets given conditions exists param: array $conditions SQL conditions array return: boolean True if such a record exists |
find($conditions = null, $fields = null, $order = null, $recursive = null) X-Ref |
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. param: array $conditions SQL conditions array param: mixed $fields Either a single string of a field name, or an array of field names param: string $order SQL ORDER BY conditions (e.g. "price DESC" or "name ASC") param: int $recursive The number of levels deep to fetch associated records return: array Array of records |
findAll($conditions = null, $fields = null, $order = null, $limit = null, $page = 1, $recursive = null) X-Ref |
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. param: mixed $conditions SQL conditions as a string or as an array('field' =>'value',...) param: mixed $fields Either a single string of a field name, or an array of field names param: string $order SQL ORDER BY conditions (e.g. "price DESC" or "name ASC") param: int $limit SQL LIMIT clause, for calculating items per page. param: int $page Page number, for accessing paged data param: int $recursive The number of levels deep to fetch associated records return: array Array of records |
__resetAssociations() X-Ref |
Method is called only when bindTo<ModelName>() is used. This resets the association arrays for the model back to the original as set in the model. return: boolean |
execute($data) X-Ref |
Runs a direct query against the bound DataSource, and returns the result. param: string $data Query data return: array |
findCount($conditions = null, $recursive = 0) X-Ref |
Returns number of rows matching given SQL condition. param: array $conditions SQL conditions array for findAll param: int $recursize The number of levels deep to fetch associated records return: int Number of matching rows |
findAllThreaded($conditions = null, $fields = null, $sort = null) X-Ref |
Special findAll variation for tables joined to themselves. The table needs the fields id and parent_id to work. param: array $conditions Conditions for the findAll() call param: array $fields Fields for the findAll() call param: string $sort SQL ORDER BY statement return: array |
__doThread($data, $root) X-Ref |
Private, recursive helper method for findAllThreaded. param: array $data param: string $root NULL or id for root node of operation return: array |
findNeighbours($conditions = null, $field, $value) X-Ref |
Returns an array with keys "prev" and "next" that holds the id's of neighbouring data, which is useful when creating paged lists. param: string $conditions SQL conditions for matching rows param: string $field Field name (parameter for findAll) param: unknown_type $value return: array Array with keys "prev" and "next" that holds the id's |
query() X-Ref |
Returns a resultset for given SQL statement. Generic SQL queries should be made with this method. param: string $sql SQL statement return: array Resultset |
validates($data = array() X-Ref |
Returns true if all fields pass validation, otherwise false. param: array $data POST data return: boolean True if there are no errors |
invalidFields($data = array() X-Ref |
Returns an array of invalid fields. param: array $data return: array Array of invalid fields or boolean case any error occurs |
invalidate($field) X-Ref |
Sets a field as invalid param: string $field The name of the field to invalidate return: void |
isForeignKey($field) X-Ref |
Returns true if given field name is a foreign key in this Model. param: string $field Returns true if the input string ends in "_id" return: True if the field is a foreign key listed in the belongsTo array. |
getDisplayField() X-Ref |
Gets the display field for this model return: string The name of the display field for this Model (i.e. 'name', 'title'). |
generateList($conditions = null, $order = null, $limit = null, $keyPath = null, $valuePath = null) X-Ref |
Returns a resultset array with specified fields from database matching given conditions. Method can be used to generate option lists for SELECT elements. param: mixed $conditions SQL conditions as a string or as an array('field' =>'value',...) param: string $order SQL ORDER BY conditions (e.g. "price DESC" or "name ASC") param: int $limit SQL LIMIT clause, for calculating items per page param: string $keyPath A string path to the key, i.e. "{n}.Post.id" param: string $valuePath A string path to the value, i.e. "{n}.Post.title" return: array An associative array of records, where the id is the key, and the display field is the value |
escapeField($field) X-Ref |
Escapes the field name and prepends the model name. Escaping will be done according to the current database driver's rules. param: unknown_type $field return: string The name of the escaped field for this Model (i.e. id becomes `Post`.`id`). |
getID($list = 0) X-Ref |
Returns the current record's ID param: unknown_type $list return: mixed The ID of the current record |
getLastInsertID() X-Ref |
Returns the ID of the last record this Model inserted return: mixed |
getInsertID() X-Ref |
Returns the ID of the last record this Model inserted return: mixed |
getNumRows() X-Ref |
Returns the number of rows returned from the last query return: int |
getAffectedRows() X-Ref |
Returns the number of rows affected by the last query return: int |
setDataSource($dataSource = null) X-Ref |
Sets the DataSource to which this model is bound param: string $dataSource The name of the DataSource, as defined in Connections.php return: boolean True on success |
beforeFind(&$queryData) X-Ref |
Before find callback param: array $queryData Data used to execute this query, i.e. conditions, order, etc. return: boolean True if the operation should continue, false if it should abort |
afterFind($results) X-Ref |
After find callback. Can be used to modify any results returned by find and findAll. param: mixed $results The results of the find operation return: mixed Result of the find operation |
beforeSave() X-Ref |
Before save callback return: boolean True if the operation should continue, false if it should abort |
afterSave() X-Ref |
After save callback return: boolean |
beforeDelete() X-Ref |
Before delete callback return: boolean True if the operation should continue, false if it should abort |
afterDelete() X-Ref |
After delete callback return: boolean |
beforeValidate() X-Ref |
Before validate callback return: boolean |
_clearCache($type = null) X-Ref |
Private method. Clears cache for this model param: string $type If null this deletes cached views if CACHE_CHECK is true return: boolean true on delete |
__sleep() X-Ref |
Called when serializing a model return: array |
__wakeup() X-Ref |
Called when unserializing a model return: void |
Généré le : Sun Feb 25 19:27:47 2007 | par Balluche grâce à PHPXref 0.7 |