AppModel Class Info:

Class Declaration:
class AppModel extends Model
File name:
Summary:
Application model for Cake. Add your application-wide methods in the class below, your models will inherit them.
Class Inheritance

Model Overloadable Object

package
cake
subpackage
cake.app

Properties:

Show/Hide parent properties
public actsAs List of behaviors to load when the model object is initialized. Settings can be passed to behaviors by using the behavior name as index. Eg: var $actsAs = array('Translate', 'MyBehavior' => array('setting1' => 'value1'))
public alias Alias name for model.
public Behaviors Holds the Behavior objects currently bound to this model.
public belongsTo Detailed list of belongsTo associations.
public cacheQueries Whether or not to cache queries for this model. This enables in-memory caching only, the results are not stored beyond the current request.
public cacheSources Whether or not to cache sources for this model.
public data Container for the data that this model gets from persistent storage (usually, a database).
public displayField Custom display field name. Display fields are used by Scaffold, in SELECT boxes' OPTION elements.
protected _findMethods List of valid finder method options, supplied as the first parameter to find().
public findQueryType Type of find query currently executing.
public hasAndBelongsToMany Detailed list of hasAndBelongsToMany associations.
public hasMany Detailed list of hasMany associations.
public hasOne Detailed list of hasOne associations.
public id Value of the primary key ID of the record that this model is currently pointing to. Automatically set after database insertions.
protected _log Log object
public logTransactions Whether or not to log transactions for this model.
public name Name of the model.
public order The column name(s) and direction(s) to order find results by default. var $order = "Post.created DESC"; var $order = array("Post.view_count DESC", "Post.rating DESC");
public primaryKey The name of the primary key field for this model.
public recursive Number of associations to recurse through during find calls. Fetches only the first level by default.
protected _schema Field-by-field table metadata.
public table Table name for this Model.
public tablePrefix Database table prefix for tables in model.
public tableToModel List of table names included in the model description. Used for associations.
public transactional Whether or not to enable transactions for this model (i.e. BEGIN/COMMIT/ROLLBACK statements)
public useDbConfig The name of the DataSource connection that this Model uses
public useTable Custom database table name, or null/false if no table association is desired.
public validate List of validation rules. Append entries for validation as ('field_name' => '/^perl_compat_regexp$/') that have to match with preg_match(). Use these rules with Model::validate()
public validationErrors List of validation errors.
public whitelist Whitelist of fields allowed to be saved.

Method Summary:

Show/Hide parent methods
public afterDelete( )
public afterFind( $results, $primary = false )
public afterSave( $created )
public beforeDelete( $cascade = true )
public beforeFind( $queryData )
public beforeSave( $options = array ( ) )
public beforeValidate( $options = array ( ) )
public bind( $model, $options = array ( ), $permanent = true )
public bindModel( $params, $reset = true )
public cakeError( $method, $messages = array ( ) )
protected call__( $method, $params )
protected _clearCache( $type = NULL )
public __construct( $id = false, $table = NULL, $ds = NULL )
public create( $data = array ( ), $filterKey = false )
public deconstruct( $field, $data )
public del( $id = NULL, $cascade = true )
public delete( $id = NULL, $cascade = true )
public deleteAll( $conditions, $cascade = true, $callbacks = false )
protected _deleteDependent( $id, $cascade )
protected _deleteLinks( $id )
public dispatchMethod( $method, $params = array ( ) )
public escapeField( $field = NULL, $alias = NULL )
public exists( $reset = false )
public field( $name, $conditions = NULL, $order = NULL )
public find( $conditions = NULL, $fields = array ( ), $order = NULL, $recursive = NULL )
public findAll( $conditions = NULL, $fields = NULL, $order = NULL, $limit = NULL, $page = 1, $recursive = NULL )
public findAllThreaded( $conditions = NULL, $fields = NULL, $order = NULL )
protected _findCount( $state, $query, $results = array ( ) )
public findCount( $conditions = NULL, $recursive = 0 )
protected _findFirst( $state, $query, $results = array ( ) )
protected _findList( $state, $query, $results = array ( ) )
protected _findNeighbors( $state, $query, $results = array ( ) )
public findNeighbours( $conditions, $field, $value )
protected _findThreaded( $state, $query, $results = array ( ) )
public getAffectedRows( )
public getAssociated( $type = NULL )
public getColumnType( $column )
public getColumnTypes( )
public getDataSource( )
public getDisplayField( )
public getID( $list = 0 )
public getInsertID( )
public getLastInsertID( )
public getNumRows( )
public hasAny( $conditions = NULL )
public hasField( $name )
public invalidate( $field, $value = true )
public invalidFields( $options = array ( ) )
public isForeignKey( $field )
public isUnique( $fields, $or = true )
public joinModel( $assoc, $keys = array ( ) )
public log( $msg, $type = 2 )
public Object( )
public onError( )
public overload( )
protected _persist( $name, $return, $object, $type = NULL )
protected _prepareUpdateFields( $data )
public query( )
public read( $fields = NULL, $id = NULL )
public remove( $id = NULL, $cascade = true )
public requestAction( $url, $extra = array ( ) )
public resetAssociations( )
public save( $data = NULL, $validate = true, $fieldList = array ( ) )
public saveAll( $data = NULL, $options = array ( ) )
public saveField( $name, $value, $validate = false )
protected _savePersistent( $name, $object )
public schema( $field = false )
public set( $one, $two = NULL )
protected _set( $properties = array ( ) )
public setDataSource( $dataSource = NULL )
public setInsertID( $id )
public setSource( $tableName )
public _stop( $status = 0 )
public toString( )
public unbindModel( $params, $reset = true )
public updateAll( $fields, $conditions = true )
public updateCounterCache( $keys = array ( ), $created = false )
public validates( $options = array ( ) )

afterDelete

top
Called after every deletion operation.
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 2785

afterFind

top
Called after each find operation. Can be used to modify any results returned by find(). Return value should be the (modified) results.
Parameters:
$results mixed The results of the find operation required (no default)
$primary boolean Whether this model is being queried directly (vs. being queried as an association) optional false
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 2745
return
mixed Result of the find operation
access
public
link
http://book.cakephp.org/view/681/afterFind

afterSave

top
Called after each successful save operation.
Parameters:
$created boolean True if this save created a new record required (no default)
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 2766

beforeDelete

top
Called before every deletion operation.
Parameters:
$cascade boolean If true records that depend on this record will also be deleted optional true
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 2776
return
boolean True if the operation should continue, false if it should abort
access
public
link
http://book.cakephp.org/view/685/beforeDelete

beforeFind

top
Called before each find operation. Return false if you want to halt the find call, otherwise return the (modified) query data.
Parameters:
$queryData array Data used to execute this query, i.e. conditions, order, etc. required (no default)
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 2732
return
mixed true if the operation should continue, false if it should abort; or, modified $queryData to continue with new $queryData
access
public
link
http://book.cakephp.org/view/680/beforeFind

beforeSave

top
Called before each save operation, after validation. Return a non-true result to halt the save.
Parameters:
$options optional array ( )
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 2756
return
boolean True if the operation should continue, false if it should abort
access
public
link
http://book.cakephp.org/view/683/beforeSave

beforeValidate

top
Called during save operations, before validation. Please note that custom validation rules can be defined in $validate.
Parameters:
$options optional array ( )
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 2796
return
boolean True if validate operation should continue, false to abort
access
public
link
http://book.cakephp.org/view/682/beforeValidate

bind

top
Bind model associations on the fly. If $permanent is true, association will not be reset to the originals defined in the model. be bound
Parameters:
$model mixed A model or association name (string) or set of binding options (indexed by model name type) required (no default)
$options array If $model is a string, this is the list of association properties with which $model will optional array ( )
$permanent boolean Set to true to make the binding permanent optional true
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 462
return
void
access
public
todo

bindModel

top
Bind model associations on the fly. If $reset is false, association will not be reset to the originals defined in the model Example: Add a new hasOne binding to the Profile model not defined in the model source code: <code> $this->User->bindModel( array('hasOne' => array('Profile')) ); </code>
Parameters:
$params array Set of bindings (indexed by binding type) required (no default)
$reset boolean Set to false to make the binding permanent optional true
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 515

cakeError

top
Used to report user friendly errors. If there is a file app/error.php or app/app_error.php this file will be loaded error.php is the AppError class it should extend ErrorHandler class.
Parameters:
$method string Method to be called in the error class (AppError or ErrorHandler classes) required (no default)
$messages array Message that is to be displayed by the error class optional array ( )
Method defined in class:
Object
Method defined in file:
cake/libs/object.php on line 189
return
error message
access
public

call__

top
Handles custom method calls, like findBy<field> for DB models, and custom RPC calls for remote data sources.
Parameters:
$method string Name of method to call. required (no default)
$params array Parameters for the method. required (no default)
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 434
return
mixed Whatever is returned by called method
access
protected

_clearCache

top
Private method. Clears cache for this model.
Parameters:
$type string If null this deletes cached views if Cache.check is true Will be used to allow deleting query cache also optional NULL
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 2816
return
boolean true on delete
access
protected
todo

__construct

top
Constructor. Binds the model's database table to the object.
Parameters:
$id integer Set this ID for this model on startup optional false
$table string Name of database table to use. optional NULL
$ds object DataSource connection object. optional NULL
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 340

create

top
Initializes the model for writing a new record, loading the default values for those fields that are not defined in $data. Especially helpful for saving data in loops.
Parameters:
$data mixed Optional data array to assign to the model after it is created. If null or false, schema data defaults are not merged. optional array ( )
$filterKey boolean If true, overwrites any primary key input with an empty value optional false
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 996
return
array The current Model::data; after merging $data and/or defaults from database
access
public
link
http://book.cakephp.org/view/75/Saving-Your-Data

deconstruct

top
Deconstructs a complex data type (array or object) into a single field value.
Parameters:
$field string The name of the field to be deconstructed required (no default)
$data mixed An array or object to be deconstructed into a field required (no default)
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 821
return
mixed The resulting data that should be assigned to a field
access
public

del

top
Removes record for given ID. If no ID is given, the current ID is used. Returns true on success.
Parameters:
$id mixed ID of record to delete optional NULL
$cascade boolean Set to true to delete records that depend on this record optional true
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 1699
return
boolean True on success
access
public
link
http://book.cakephp.org/view/690/del

delete

top
Alias for del().
Parameters:
$id mixed ID of record to delete optional NULL
$cascade boolean Set to true to delete records that depend on this record optional true
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 1741
return
boolean True on success
access
public
see
Model::del()

deleteAll

top
Deletes multiple model records based on a set of conditions.
Parameters:
$conditions mixed Conditions to match required (no default)
$cascade boolean Set to true to delete records that depend on this record optional true
$callbacks boolean Run callbacks (not being used) optional false
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 1817
return
boolean True on success, false on failure
access
public
link
http://book.cakephp.org/view/692/deleteAll

_deleteDependent

top
Cascades model deletes through associated hasMany and hasOne child records.
Parameters:
$id string ID of record that was deleted required (no default)
$cascade boolean Set to true to delete records that depend on this record required (no default)
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 1752
return
void
access
protected

_deleteLinks

top
Cascades model deletes through HABTM join keys.
Parameters:
$id string ID of record that was deleted required (no default)
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 1791
return
void
access
protected

dispatchMethod

top
Calls a method on this object with the given parameters. Provides an OO wrapper for call_user_func_array, and improves performance by using straight method calls in most cases.
Parameters:
$method string Name of the method to call required (no default)
$params array Parameter list to use when calling $method optional array ( )
Method defined in class:
Object
Method defined in file:
cake/libs/object.php on line 113
return
mixed Returns the result of the method call
access
public

escapeField

top
Escapes the field name and prepends the model name. Escaping is done according to the current database driver's rules.
Parameters:
$field string Field to escape (e.g: id) optional NULL
$alias string Alias for the model (e.g: Post) optional NULL
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 2535
return
string The name of the escaped field for this Model (i.e. id becomes `Post`.`id`).
access
public

exists

top
Returns true if a record with the currently set ID exists.
Parameters:
$reset boolean if true will force database query optional false
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 1877
return
boolean True if such a record exists
access
public

field

top
Returns the contents of a single field given the supplied conditions, in the supplied order.
Parameters:
$name string Name of field to get required (no default)
$conditions array SQL conditions (defaults to NULL) optional NULL
$order string SQL ORDER BY fragment optional NULL
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 1060
return
string field contents, or false if not found
access
public
link
http://book.cakephp.org/view/453/field

find

top
Returns a result set array. Also used to perform new-notation finds, where the first argument is type of find operation to perform (all / first / count / neighbors / list / threaded ), second parameter options for finding ( indexed array, including: 'conditions', 'limit', 'recursive', 'page', 'fields', 'offset', 'order') Eg: find('all', array( 'conditions' => array('name' => 'Thomas Anderson'), 'fields' => array('name', 'email'), 'order' => 'field3 DESC', 'recursive' => 2, 'group' => 'type')); Specifying 'fields' for new-notation 'list': - If no fields are specified, then 'id' is used for key and 'model->displayField' is used for value. - If a single field is specified, 'id' is used for key and specified field is used for value. - If three fields are specified, they are used (in order) for key, value and group. - Otherwise, first and second fields are used for key and value.
Parameters:
$conditions array SQL conditions array, or type of find operation (all / first / count / neighbors / list / threaded) optional NULL
$fields mixed Either a single string of a field name, or an array of field names, or options for matching optional array ( )
$order string SQL ORDER BY conditions (e.g. "price DESC" or "name ASC") optional NULL
$recursive integer The number of levels deep to fetch associated records optional NULL
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 1935
return
array Array of records
access
public
link
http://book.cakephp.org/view/449/find

findAll

top
Parameters:
$conditions optional NULL
$fields optional NULL
$order optional NULL
$limit optional NULL
$page optional 1
$recursive optional NULL
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 2859
deprecated
see
Model::find('all')

findAllThreaded

top
Parameters:
$conditions optional NULL
$fields optional NULL
$order optional NULL
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 2875
deprecated
see
Model::find('threaded')

_findCount

top
Handles the before/after filter logic for find('count') operations. Only called by Model::find().
Parameters:
$state string Either "before" or "after" required (no default)
$query array Either "before" or "after" required (no default)
$results optional array ( )
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 2040
return
int The number of records found, or false
access
protected
see
Model::find()

findCount

top
Parameters:
$conditions optional NULL
$recursive optional 0
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 2867
deprecated
see
Model::find('count')

_findFirst

top
Handles the before/after filter logic for find('first') operations. Only called by Model::find().
Parameters:
$state string Either "before" or "after" required (no default)
$query array Either "before" or "after" required (no default)
$results optional array ( )
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 2016
return
array
access
protected
see
Model::find()

_findList

top
Handles the before/after filter logic for find('list') operations. Only called by Model::find().
Parameters:
$state string Either "before" or "after" required (no default)
$query array Either "before" or "after" required (no default)
$results optional array ( )
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 2071
return
array Key/value pairs of primary keys/display field values of all records found
access
protected
see
Model::find()

_findNeighbors

top
Detects the previous field's value, then uses logic to find the 'wrapping' rows and return them.
Parameters:
$state string Either "before" or "after" required (no default)
$query mixed Either "before" or "after" required (no default)
$results array Either "before" or "after" optional array ( )
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 2129
return
array
access
protected

findNeighbours

top
Parameters:
$conditions required (no default)
$field required (no default)
$value required (no default)
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 2883
deprecated
see
Model::find('neighbors')

_findThreaded

top
In the event of ambiguous results returned (multiple top level results, with different parent_ids) top level results with different parent_ids to the first result will be dropped
Parameters:
$state mixed required (no default)
$query mixed required (no default)
$results array optional array ( )
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 2187
return
array Threaded results
access
protected

getAffectedRows

top
Returns the number of rows affected by the last query.
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 2623
return
int Number of rows
access
public

getAssociated

top
Gets all the models with which this model is associated.
Parameters:
$type string Only result associations of this type optional NULL
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 2673
return
array Associations
access
public

getColumnType

top
Returns the column type of a column in the model.
Parameters:
$column string The name of the model column required (no default)
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 938
return
string Column type
access
public

getColumnTypes

top
Returns an associative array of field names and column types.
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 920
return
array Field types indexed by field name
access
public

getDataSource

top
Gets the DataSource to which this model is bound. Not safe for use with some versions of PHP4, because this class is overloaded.
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 2662
return
object A DataSource object
access
public

getDisplayField

top
Returns the display field for this model.
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 2524
return
string The name of the display field for this Model (i.e. 'name', 'title').
access
public
deprecated

getID

top
Returns the current record's ID
Parameters:
$list integer Index on which the composed ID is located optional 0
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 2555
return
mixed The ID of the current record, false if no ID
access
public

getInsertID

top
Returns the ID of the last record this model inserted.
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 2595
return
mixed Last inserted ID
access
public

getLastInsertID

top
Returns the ID of the last record this model inserted.
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 2586
return
mixed Last inserted ID
access
public

getNumRows

top
Returns the number of rows returned from the last query.
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 2613
return
int Number of rows
access
public

hasAny

top
Returns true if a record that meets given conditions exists.
Parameters:
$conditions array SQL conditions array optional NULL
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 1903
return
boolean True if such a record exists
access
public

hasField

top
Returns true if the supplied field exists in the model's database table.
Parameters:
$name mixed Name of field to look for, or an array of names required (no default)
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 965
return
mixed If $name is a string, returns a boolean indicating whether the field exists. If $name is an array of field names, returns the first field that exists, or false if none exist.
access
public

invalidate

top
Marks a field as invalid, optionally setting the name of validation rule (in case of multiple validation for field) that was broken.
Parameters:
$field string The name of the field to invalidate required (no default)
$value mixed Name of validation rule that was not failed, or validation message to be returned. If no validation key is provided, defaults to true. optional true
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 2495
access
public

invalidFields

top
Returns an array of fields that have failed validation.
Parameters:
$options string An optional array of custom options to be made available in the beforeValidate callback optional array ( )
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 2344
return
array Array of invalid fields
access
public
link
http://book.cakephp.org/view/410/Validating-Data-from-the-Controller

isForeignKey

top
Returns true if given field name is a foreign key in this model.
Parameters:
$field string Returns true if the input string ends in "_id" required (no default)
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 2508
return
boolean True if the field is a foreign key listed in the belongsTo array.
access
public

isUnique

top
Returns false if any fields passed match any (by default, all if $or = false) of their matching values.
Parameters:
$fields array Field/value pairs to search (if no values specified, they are pulled from $this->data) required (no default)
$or boolean If false, all fields specified must match in order for a false return value optional true
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 2274
return
boolean False if any records matching any fields are found
access
public

joinModel

top
Gets the name and fields to be used by a join model. This allows specifying join fields in the association definition.
Parameters:
$assoc required (no default)
$keys array Any join keys which must be merged with the keys queried optional array ( )
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 2713
return
array
access
public

log

top
API for logging events.
Parameters:
$msg string Log message required (no default)
$type integer Error type constant. Defined in app/config/core.php. optional 2
Method defined in class:
Object
Method defined in file:
cake/libs/object.php on line 150
return
boolean Success of log write
access
public

Object

top
A hack to support __construct() on PHP 4 Hint: descendant classes have no PHP4 class_name() constructors, so this constructor gets called first and calls the top-layer __construct() which (if present) should call parent::__construct()
Method defined in class:
Object
Method defined in file:
cake/libs/object.php on line 53
return
Object

onError

top
Called when a DataSource-level error occurs.
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 2805

overload

top
Overload implementation. No need for implementation in PHP5.
Method defined in class:
Overloadable
Method defined in file:
cake/libs/overloadable_php5.php on line 39
access
public

_persist

top
Checks for a persistent class file, if found file is opened and true returned If file is not found a file is created and false returned If used in other locations of the model you should choose a unique name for the persistent file There are many uses for this method, see manual for examples
Parameters:
$name string name of the class to persist required (no default)
$return required (no default)
$object string the object to persist required (no default)
$type optional NULL
Method defined in class:
Object
Method defined in file:
cake/libs/object.php on line 219
return
boolean Success
access
protected
todo
add examples to manual

_prepareUpdateFields

top
Helper method for Model::updateCounterCache(). Checks the fields to be updated for
Parameters:
$data array The fields of the record that will be updated required (no default)
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 1439
return
array Returns updated foreign key values, along with an 'old' key containing the old values, or empty if no foreign keys are updated.
access
protected

query

top
Returns a resultset for a given SQL statement. Custom SQL queries should be performed with this method.
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 2316
return
array Resultset
access
public
link
http://book.cakephp.org/view/456/query

read

top
Returns a list of fields from the database, and sets the current model data (Model::$data) with the record found.
Parameters:
$fields mixed String of single fieldname, or an array of fieldnames. optional NULL
$id mixed The ID of the record to read optional NULL
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 1026
return
array Array of database fields, or false if not found
access
public

remove

top
Alias for del().
Parameters:
$id mixed ID of record to delete optional NULL
$cascade boolean Set to true to delete records that depend on this record optional true
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 1687
return
boolean True on success
access
public
see
Model::del()
link
http://book.cakephp.org/view/691/remove

requestAction

top
Calls a controller's method from any location.
Parameters:
$url mixed String or array-based url. required (no default)
$extra array if array includes the key "return" it sets the AutoRender to true. optional array ( )
Method defined in class:
Object
Method defined in file:
cake/libs/object.php on line 86
return
mixed Boolean true or false on success/failure, or contents of rendered action if 'return' is set in $extra.
access
public

resetAssociations

top
Called only when bindTo<ModelName>() is used. This resets the association arrays for the model back to those originally defined in the model.
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 2246
return
boolean Success
access
public

save

top
Saves model data (based on white-list, if supplied) to the database. By default, validation occurs before save. If a boolean, indicates whether or not to validate before saving. If an array, allows control of validate, callbacks, and fieldList
Parameters:
$data array Data to save. optional NULL
$validate mixed Either a boolean, or an array. optional true
$fieldList array List of fields to allow to be written optional array ( )
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 1124
return
mixed On success Model::$data if its not empty or true, false on failure
access
public
link
http://book.cakephp.org/view/75/Saving-Your-Data

saveAll

top
Saves multiple individual records for a single model; Also works with a single record, as well as all its associated records. records of the same type), or an array indexed by association name. - validate: Set to false to disable validation, true to validate each record before saving, 'first' to validate *all* records before any are saved, or 'only' to only validate the records, but not save them. - atomic: If true (default), will attempt to save all records in a single transaction. Should be set to false if database/table does not support transactions. If false, we return an array similar to the $data array passed, but values are set to true/false depending on whether each record saved successfully. - fieldList: Equivalent to the $fieldList parameter in Model::save()
Parameters:
$data array Record data to save. This can be either a numerically-indexed array (for saving multiple optional NULL
$options array Options to use when saving record data, which are as follows: optional array ( )
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 1478
return
mixed True on success, or false on failure
access
public
link
Array

saveField

top
Saves the value of a single field to the database, based on the current model ID.
Parameters:
$name string Name of the table field required (no default)
$value mixed Value of the field required (no default)
$validate array See $options param in Model::save(). Does not respect 'fieldList' key if passed optional false
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 1100

_savePersistent

top
You should choose a unique name for the persistent file There are many uses for this method, see manual for examples
Parameters:
$name string name used for object to cache required (no default)
$object object the object to persist required (no default)
Method defined in class:
Object
Method defined in file:
cake/libs/object.php on line 247
return
boolean true on save, throws error if file can not be created
access
protected

schema

top
Returns an array of table metadata (column names and types) from the database. $field => keys(type, null, default, key, length, extra)
Parameters:
$field mixed Set to true to reload schema, or a string to return a specific field optional false
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 895
return
array Array of table metadata
access
public

set

top
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.)
Parameters:
$one mixed Array or string of data required (no default)
$two string Value string for the alternative indata method optional NULL
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 772
return
array Data with all of $one's keys and values
access
public

_set

top
Allows setting of multiple properties of the object in a single line of code.
Parameters:
$properties array An associative array containing properties and corresponding values. optional array ( )
Method defined in class:
Object
Method defined in file:
cake/libs/object.php on line 169
return
void
access
protected

setDataSource

top
Sets the DataSource to which this model is bound.
Parameters:
$dataSource string The name of the DataSource, as defined in app/config/database.php optional NULL
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 2634
return
boolean True on success
access
public

setInsertID

top
Sets the ID of the last record this model inserted
Parameters:
$id required (no default)
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 2604
access
public

setSource

top
Sets a custom table for your controller class. Used by your controller to select a database table.
Parameters:
$tableName string Name of the custom table required (no default)
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 740
return
void
access
public

_stop

top
Stop execution of the current script
Parameters:
$status optional 0
Method defined in class:
Object
Method defined in file:
cake/libs/object.php on line 139
return
void
access
public

toString

top
Object-to-string conversion. Each class can override this method as necessary.
Method defined in class:
Object
Method defined in file:
cake/libs/object.php on line 73
return
string The name of this class
access
public

unbindModel

top
Turn off associations on the fly. If $reset is false, association will not be reset to the originals defined in the model Example: Turn off the associated Model Support request, to temporarily lighten the User model: <code> $this->User->unbindModel( array('hasMany' => array('Supportrequest')) ); </code>
Parameters:
$params array Set of bindings to unbind (indexed by binding type) required (no default)
$reset boolean Set to false to make the unbinding permanent optional true
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 553

updateAll

top
Updates multiple model records based on a set of conditions. Fields are treated as SQL snippets, to insert literal values manually escape your data.
Parameters:
$fields array Set of fields and values, indexed by fields. required (no default)
$conditions mixed Conditions to match, true for all records optional true
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 1673
return
boolean True on success, false on failure
access
public
link
http://book.cakephp.org/view/75/Saving-Your-Data

updateCounterCache

top
Updates the counter cache of belongsTo associations after a save or delete operation 'counterScope' defined get updated
Parameters:
$keys array Optional foreign key data, defaults to the information $this->data optional array ( )
$created boolean True if a new record was created, otherwise only associations with optional false
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 1384
return
void
access
public

validates

top
Returns true if all fields pass validation.
Parameters:
$options string An optional array of custom options to be made available in the beforeValidate callback optional array ( )
Method defined in class:
Model
Method defined in file:
cake/libs/model/model.php on line 2329
return
boolean True if there are no errors
access
public
link
http://book.cakephp.org/view/410/Validating-Data-from-the-Controller