AcoAction Class Info:
- Class Declaration:
class AcoAction extends AppModel
- File name:
- cake/libs/model/db_acl.php
- Description:
Action for Access Control Object
- Class Inheritance
- Package
- cake
- Subpackage
- cake.cake.libs.model
Properties:
-
actsAs array
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'))
-
__affectedRows integer
The number of records affected by the last query.
-
alias string
Alias name for model.
-
__associationKeys array
Default list of association keys.
-
__associations array
Holds provided/generated association key names and other data for all associations.
-
__backAssociation array
Holds model associations temporarily to allow for dynamic (un)binding.
-
Behaviors BehaviorCollection
Holds the Behavior objects currently bound to this model.
-
belongsTo array
ACO Actions belong to ACOs
-
cacheQueries boolean
Whether or not to cache queries for this model. This enables in-memory caching only, the results are not stored beyond the current request.
-
cacheSources boolean
Whether or not to cache sources for this model.
-
data array
Container for the data that this model gets from persistent storage (usually, a database).
-
displayField string
Custom display field name. Display fields are used by Scaffold, in SELECT boxes' OPTION elements.
-
_findMethods array
List of valid finder method options, supplied as the first parameter to find().
-
findQueryType string
Type of find query currently executing.
-
hasAndBelongsToMany array
Detailed list of hasAndBelongsToMany associations.
-
hasMany array
Detailed list of hasMany associations.
-
hasOne array
Detailed list of hasOne associations.
-
id mixed
Value of the primary key ID of the record that this model is currently pointing to. Automatically set after database insertions.
-
__insertID integer
The ID of the model record that was last inserted.
-
logTransactions boolean
Whether or not to log transactions for this model.
-
name string
Model name
-
__numRows integer
The number of records returned by the last query.
-
order string
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");
-
primaryKey string
The name of the primary key field for this model.
-
recursive integer
Number of associations to recurse through during find calls. Fetches only the first level by default.
-
_schema array
Field-by-field table metadata.
-
table string
Table name for this Model.
-
tablePrefix string
Database table prefix for tables in model.
-
tableToModel array
List of table names included in the model description. Used for associations.
-
useDbConfig string
The name of the DataSource connection that this Model uses
-
useTable string
Custom database table name, or null/false if no table association is desired.
-
validate array
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()
-
validationErrors array
List of validation errors.
-
virtualFields array
Array of virtual fields this model has. Virtual fields are aliased SQL expressions. Fields added to this property will be read as other fields in a model but will not be saveable.
var $virtualFields = array('two' => '1 + 1');Is a simplistic example of how to set virtualFields
-
whitelist array
Whitelist of fields allowed to be saved.
Method Summary:
- afterDelete( )
- afterFind( $results, $primary = false )
- afterSave( $created )
- beforeDelete( $cascade = true )
- beforeFind( $queryData )
- beforeSave( $options = array ( ) )
- beforeValidate( $options = array ( ) )
- bindModel( $params, $reset = true )
- cakeError( $method, $messages = array ( ) )
- call__( $method, $params )
- __call( $method, $params )
- _clearCache( $type = NULL )
- __collectForeignKeys( $type = 'belongsTo' )
- __construct( $id = false, $table = NULL, $ds = NULL )
- __constructLinkedModel( $assoc, $className = NULL )
- create( $data = array ( ), $filterKey = false )
- __createLinks( )
- deconstruct( $field, $data )
- delete( $id = NULL, $cascade = true )
- deleteAll( $conditions, $cascade = true, $callbacks = false )
- _deleteDependent( $id, $cascade )
- _deleteLinks( $id )
- dispatchMethod( $method, $params = array ( ) )
- escapeField( $field = NULL, $alias = NULL )
- exists( )
- field( $name, $conditions = NULL, $order = NULL )
- __filterResults( $results, $primary = true )
- find( $conditions = NULL, $fields = array ( ), $order = NULL, $recursive = NULL )
- _findCount( $state, $query, $results = array ( ) )
- _findFirst( $state, $query, $results = array ( ) )
- _findList( $state, $query, $results = array ( ) )
- _findNeighbors( $state, $query, $results = array ( ) )
- _findThreaded( $state, $query, $results = array ( ) )
- __generateAssociation( $type )
- getAffectedRows( )
- getAssociated( $type = NULL )
- getColumnType( $column )
- getColumnTypes( )
- getDataSource( )
- getID( $list = 0 )
- getInsertID( )
- getLastInsertID( )
- getNumRows( )
- getVirtualField( $field = NULL )
- hasAny( $conditions = NULL )
- hasField( $name, $checkVirtual = false )
- invalidate( $field, $value = true )
- invalidFields( $options = array ( ) )
- isForeignKey( $field )
- isUnique( $fields, $or = true )
- isVirtualField( $field )
- joinModel( $assoc, $keys = array ( ) )
- log( $msg, $type = 2 )
- Object( )
- onError( )
- __openPersistent( $name, $type = NULL )
- overload( )
- _persist( $name, $return, $object, $type = NULL )
- _prepareUpdateFields( $data )
- query( )
- read( $fields = NULL, $id = NULL )
- requestAction( $url, $extra = array ( ) )
- resetAssociations( )
- save( $data = NULL, $validate = true, $fieldList = array ( ) )
- __save( $data, $options )
- saveAll( $data = NULL, $options = array ( ) )
- saveField( $name, $value, $validate = false )
- __saveMulti( $joined, $id, $db )
- _savePersistent( $name, $object )
- schema( $field = false )
- set( $one, $two = NULL )
- _set( $properties = array ( ) )
- setDataSource( $dataSource = NULL )
- setInsertID( $id )
- setSource( $tableName )
- __sleep( )
- _stop( $status = 0 )
- toString( )
- unbindModel( $params, $reset = true )
- updateAll( $fields, $conditions = true )
- updateCounterCache( $keys = array ( ), $created = false )
- validates( $options = array ( ) )
- __validateWithModels( $options )
- __wakeup( )
afterDelete
topCalled after every deletion operation.
- Method defined in:
- cake/libs/model/model.php on line 2956
- Access
public
- Link
- http://book.cakephp.org/view/1048/Callback-Methods#afterDelete-1055
afterFind
topCalled after each find operation. Can be used to modify any results returned by find(). Return value should be the (modified) results.
- Parameters:
-
-
mixed $results required
The results of the find operation
-
boolean $primary optional false
Whether this model is being queried directly (vs. being queried as an association)
-
- Method defined in:
- cake/libs/model/model.php on line 2912
- Return
mixed Result of the find operation
- Access
public
- Link
- http://book.cakephp.org/view/1048/Callback-Methods#afterFind-1050
afterSave
topCalled after each successful save operation.
- Parameters:
-
-
boolean $created required
True if this save created a new record
-
- Method defined in:
- cake/libs/model/model.php on line 2935
- Access
public
- Link
- http://book.cakephp.org/view/1048/Callback-Methods#afterSave-1053
beforeDelete
topCalled before every deletion operation.
- Parameters:
-
-
boolean $cascade optional true
If true records that depend on this record will also be deleted
-
- Method defined in:
- cake/libs/model/model.php on line 2946
- Return
boolean True if the operation should continue, false if it should abort
- Access
public
- Link
- http://book.cakephp.org/view/1048/Callback-Methods#beforeDelete-1054
beforeFind
topCalled before each find operation. Return false if you want to halt the find call, otherwise return the (modified) query data.
- Parameters:
-
-
array $queryData required
Data used to execute this query, i.e. conditions, order, etc.
-
- Method defined in:
- cake/libs/model/model.php on line 2898
- 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/1048/Callback-Methods#beforeFind-1049
beforeSave
topCalled before each save operation, after validation. Return a non-true result to halt the save.
- Parameters:
-
-
$options optional array ( )
-
- Method defined in:
- cake/libs/model/model.php on line 2924
- Return
boolean True if the operation should continue, false if it should abort
- Access
public
- Link
- http://book.cakephp.org/view/1048/Callback-Methods#beforeSave-1052
beforeValidate
topCalled during validation operations, before validation. Please note that custom validation rules can be defined in $validate.
- Parameters:
-
-
$options optional array ( )
-
- Method defined in:
- cake/libs/model/model.php on line 2968
- Return
boolean True if validate operation should continue, false to abort
- Access
public
- Link
- http://book.cakephp.org/view/1048/Callback-Methods#beforeValidate-1051
bindModel
topBind 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:
$this->User->bindModel( array('hasOne' => array('Profile')) );
Bindings that are not made permanent will be reset by the next Model::find() call on this model.
- Parameters:
-
-
array $params required
Set of bindings (indexed by binding type)
-
boolean $reset optional true
Set to false to make the binding permanent
-
- Method defined in:
- cake/libs/model/model.php on line 530
- Return
boolean Success
- Access
public
- Link
- http://book.cakephp.org/view/1045/Creating-and-Destroying-Associations-on-the-Fly
cakeError
topUsed 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:
-
-
string $method required
Method to be called in the error class (AppError or ErrorHandler classes)
-
array $messages optional array ( )
Message that is to be displayed by the error class
-
- Method defined in:
- cake/libs/object.php on line 187
- Return
error message
- Access
public
call__
topHandles custom method calls, like findBy<field> for DB models, and custom RPC calls for remote data sources.
- Parameters:
-
-
string $method required
Name of method to call.
-
array $params required
Parameters for the method.
-
- Method defined in:
- cake/libs/model/model.php on line 495
- Return
mixed Whatever is returned by called method
- Access
protected
__call
topMagic method handler.
- Parameters:
-
-
string $method required
Method name
-
array $params required
Parameters to send to method
-
- Method defined in:
- cake/libs/overloadable_php5.php on line 46
- Return
mixed Return value from method
- Access
private
_clearCache
topPrivate method. Clears cache for this model.
- Parameters:
-
-
string $type optional NULL
If null this deletes cached views if Cache.check is true Will be used to allow deleting query cache also
-
- Method defined in:
- cake/libs/model/model.php on line 2990
- Return
boolean true on delete
- Access
protected
- Todo
__collectForeignKeys
topCollects foreign keys from associations.
- Parameters:
-
-
$type optional 'belongsTo'
-
- Method defined in:
- cake/libs/model/model.php on line 1952
- Return
array
- Access
private
__construct
topConstructor. Binds the model's database table to the object.
If $id is an array it can be used to pass several options into the model.
- id - The id to start the model on.
- table - The table to use for this model.
- ds - The connection name this model is connected to.
- name - The name of the model eg. Post.
- alias - The alias of the model, this is used for registering the instance in the
ClassRegistry. eg.ParentThread
Overriding Model's __construct method.
When overriding Model::__construct() be careful to include and pass in all 3 of the
arguments to parent::__construct($id, $table, $ds);
Dynamically creating models
You can dynamically create model instances using the the $id array syntax.
$Post = new Model(array('table' => 'posts', 'name' => 'Post', 'ds' => 'connection2'));
Would create a model attached to the posts table on connection2. Dynamic model creation is useful when you want a model object that contains no associations or attached behaviors.
- Parameters:
-
-
mixed $id optional false
Set this ID for this model on startup, can also be an array of options, see above.
-
string $table optional NULL
Name of database table to use.
-
string $ds optional NULL
DataSource connection name.
-
- Method defined in:
- cake/libs/model/model.php on line 403
__constructLinkedModel
topPrivate helper method to create associated models of a given class.
usage: $this->Assoc->modelMethods();
var $hasMany = array('ModelName');
usage: $this->ModelName->modelMethods();
- Parameters:
-
-
string $assoc required
Association name
-
string $className optional NULL
Class name
-
- Method defined in:
- cake/libs/model/model.php on line 647
- Deprecated
$this->$className use $this->$assoc instead. $assoc is the 'key' in the associations array; examples: var $hasMany = array('Assoc' => array('className' => 'ModelName'));
- Return
void
- Access
private
create
topInitializes the model for writing a new record, loading the default values for those fields that are not defined in $data, and clearing previous validation errors. Especially helpful for saving data in loops.
- Parameters:
-
-
mixed $data optional array ( )
Optional data array to assign to the model after it is created. If null or false, schema data defaults are not merged.
-
boolean $filterKey optional false
If true, overwrites any primary key input with an empty value
-
- Method defined in:
- cake/libs/model/model.php on line 1077
- Return
array The current Model::data; after merging $data and/or defaults from database
- Access
public
- Link
- http://book.cakephp.org/view/1031/Saving-Your-Data
__createLinks
topCreate a set of associations.
- Method defined in:
- cake/libs/model/model.php on line 591
- Return
void
- Access
private
deconstruct
topDeconstructs a complex data type (array or object) into a single field value.
- Parameters:
-
-
string $field required
The name of the field to be deconstructed
-
mixed $data required
An array or object to be deconstructed into a field
-
- Method defined in:
- cake/libs/model/model.php on line 845
- Return
mixed The resulting data that should be assigned to a field
- Access
public
delete
topRemoves record for given ID. If no ID is given, the current ID is used. Returns true on success.
- Parameters:
-
-
mixed $id optional NULL
ID of record to delete
-
boolean $cascade optional true
Set to true to delete records that depend on this record
-
- Method defined in:
- cake/libs/model/model.php on line 1789
- Return
boolean True on success
- Access
public
- Link
- http://book.cakephp.org/view/1036/delete
deleteAll
topDeletes multiple model records based on a set of conditions.
- Parameters:
-
-
mixed $conditions required
Conditions to match
-
boolean $cascade optional true
Set to true to delete records that depend on this record
-
boolean $callbacks optional false
Run callbacks
-
- Method defined in:
- cake/libs/model/model.php on line 1904
- Return
boolean True on success, false on failure
- Access
public
- Link
- http://book.cakephp.org/view/1038/deleteAll
_deleteDependent
topCascades model deletes through associated hasMany and hasOne child records.
- Parameters:
-
-
string $id required
ID of record that was deleted
-
boolean $cascade required
Set to true to delete records that depend on this record
-
- Method defined in:
- cake/libs/model/model.php on line 1836
- Return
void
- Access
protected
_deleteLinks
topCascades model deletes through HABTM join keys.
- Parameters:
-
-
string $id required
ID of record that was deleted
-
- Method defined in:
- cake/libs/model/model.php on line 1878
- Return
void
- Access
protected
dispatchMethod
topCalls a method on this object with the given parameters. Provides an OO wrapper
for call_user_func_array
- Parameters:
-
-
string $method required
Name of the method to call
-
array $params optional array ( )
Parameter list to use when calling $method
-
- Method defined in:
- cake/libs/object.php on line 107
- Return
mixed Returns the result of the method call
- Access
public
escapeField
topEscapes the field name and prepends the model name. Escaping is done according to the current database driver's rules.
- Parameters:
-
-
string $field optional NULL
Field to escape (e.g: id)
-
string $alias optional NULL
Alias for the model (e.g: Post)
-
- Method defined in:
- cake/libs/model/model.php on line 2681
- Return
string The name of the escaped field for this Model (i.e. id becomes
Post.id).- Access
public
exists
topReturns true if a record with the currently set ID exists.
Internally calls Model::getID() to obtain the current record ID to verify, and then performs a Model::find('count') on the currently configured datasource to ascertain the existence of the record in persistent storage.
- Method defined in:
- cake/libs/model/model.php on line 1973
- Return
boolean True if such a record exists
- Access
public
field
topReturns the contents of a single field given the supplied conditions, in the supplied order.
- Parameters:
-
-
string $name required
Name of field to get
-
array $conditions optional NULL
SQL conditions (defaults to NULL)
-
string $order optional NULL
SQL ORDER BY fragment
-
- Method defined in:
- cake/libs/model/model.php on line 1143
- Return
string field contents, or false if not found
- Access
public
- Link
- http://book.cakephp.org/view/1017/Retrieving-Your-Data#field-1028
__filterResults
topPasses query results through model and behavior afterFilter() methods.
- Parameters:
-
-
$results required
-
boolean $primary optional true
If this is the primary model results (results from model where the find operation was performed)
-
- Method defined in:
- cake/libs/model/model.php on line 2332
- Return
array Set of filtered results
- Access
private
find
topReturns 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:
-
-
array $conditions optional NULL
SQL conditions array, or type of find operation (all / first / count / neighbors / list / threaded)
-
mixed $fields optional array ( )
Either a single string of a field name, or an array of field names, or options for matching
-
string $order optional NULL
SQL ORDER BY conditions (e.g. "price DESC" or "name ASC")
-
integer $recursive optional NULL
The number of levels deep to fetch associated records
-
- Method defined in:
- cake/libs/model/model.php on line 2029
- Return
array Array of records
- Access
public
- Link
- http://book.cakephp.org/view/1018/find
_findCount
topHandles the before/after filter logic for find('count') operations. Only called by Model::find().
- Parameters:
-
-
string $state required
Either "before" or "after"
-
array $query required
Either "before" or "after"
-
$results optional array ( )
-
- Method defined in:
- cake/libs/model/model.php on line 2137
- Return
int The number of records found, or false
- Access
protected
- See
_findFirst
topHandles the before/after filter logic for find('first') operations. Only called by Model::find().
- Parameters:
-
-
string $state required
Either "before" or "after"
-
array $query required
Either "before" or "after"
-
$results optional array ( )
-
- Method defined in:
- cake/libs/model/model.php on line 2115
- Return
array
- Access
protected
- See
_findList
topHandles the before/after filter logic for find('list') operations. Only called by Model::find().
- Parameters:
-
-
string $state required
Either "before" or "after"
-
array $query required
Either "before" or "after"
-
$results optional array ( )
-
- Method defined in:
- cake/libs/model/model.php on line 2169
- Return
array Key/value pairs of primary keys/display field values of all records found
- Access
protected
- See
_findNeighbors
topDetects the previous field's value, then uses logic to find the 'wrapping' rows and return them.
- Parameters:
-
-
string $state required
Either "before" or "after"
-
mixed $query required
Either "before" or "after"
-
array $results optional array ( )
Either "before" or "after"
-
- Method defined in:
- cake/libs/model/model.php on line 2228
- Return
array
- Access
protected
_findThreaded
topIn 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:
-
-
mixed $state required
-
mixed $query required
-
array $results optional array ( )
-
- Method defined in:
- cake/libs/model/model.php on line 2287
- Return
array Threaded results
- Access
protected
__generateAssociation
topBuild an array-based association from string.
- Parameters:
-
-
string $type required
'belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany'
-
- Method defined in:
- cake/libs/model/model.php on line 675
- Return
void
- Access
private
getAffectedRows
topReturns the number of rows affected by the last query.
- Method defined in:
- cake/libs/model/model.php on line 2775
- Return
int Number of rows
- Access
public
getAssociated
topGets all the models with which this model is associated.
- Parameters:
-
-
string $type optional NULL
Only result associations of this type
-
- Method defined in:
- cake/libs/model/model.php on line 2828
- Return
array Associations
- Access
public
getColumnType
topReturns the column type of a column in the model.
- Parameters:
-
-
string $column required
The name of the model column
-
- Method defined in:
- cake/libs/model/model.php on line 965
- Return
string Column type
- Access
public
getColumnTypes
topReturns an associative array of field names and column types.
- Method defined in:
- cake/libs/model/model.php on line 946
- Return
array Field types indexed by field name
- Access
public
getDataSource
topGets 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:
- cake/libs/model/model.php on line 2816
- Return
object A DataSource object
- Access
public
getID
topReturns the current record's ID
- Parameters:
-
-
integer $list optional 0
Index on which the composed ID is located
-
- Method defined in:
- cake/libs/model/model.php on line 2702
- Return
mixed The ID of the current record, false if no ID
- Access
public
getInsertID
topReturns the ID of the last record this model inserted.
- Method defined in:
- cake/libs/model/model.php on line 2744
- Return
mixed Last inserted ID
- Access
public
getLastInsertID
topReturns the ID of the last record this model inserted.
- Method defined in:
- cake/libs/model/model.php on line 2734
- Return
mixed Last inserted ID
- Access
public
getNumRows
topReturns the number of rows returned from the last query.
- Method defined in:
- cake/libs/model/model.php on line 2764
- Return
int Number of rows
- Access
public
getVirtualField
topReturns the expression for a model virtual field
- Parameters:
-
-
$field optional NULL
-
- Method defined in:
- cake/libs/model/model.php on line 1052
- Return
mixed If $field is string expression bound to virtual field $field If $field is null, returns an array of all model virtual fields or false if none $field exist.
- Access
public
hasAny
topReturns true if a record that meets given conditions exists.
- Parameters:
-
-
array $conditions optional NULL
SQL conditions array
-
- Method defined in:
- cake/libs/model/model.php on line 1989
- Return
boolean True if such a record exists
- Access
public
hasField
topReturns true if the supplied field exists in the model's database table.
- Parameters:
-
-
mixed $name required
Name of field to look for, or an array of names
-
boolean $checkVirtual optional false
checks if the field is declared as virtual
-
- Method defined in:
- cake/libs/model/model.php on line 994
- 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
topMarks a field as invalid, optionally setting the name of validation rule (in case of multiple validation for field) that was broken.
- Parameters:
-
-
string $field required
The name of the field to invalidate
-
mixed $value optional true
Name of validation rule that was not failed, or validation message to be returned. If no validation key is provided, defaults to true.
-
- Method defined in:
- cake/libs/model/model.php on line 2648
- Access
public
invalidFields
topReturns an array of fields that have failed validation. On the current model.
- Parameters:
-
-
string $options optional array ( )
An optional array of custom options to be made available in the beforeValidate callback
-
- Method defined in:
- cake/libs/model/model.php on line 2457
- Return
array Array of invalid fields
- See
- Access
public
- Link
- http://book.cakephp.org/view/1182/Validating-Data-from-the-Controller
isForeignKey
topReturns true if given field name is a foreign key in this model.
- Parameters:
-
-
string $field required
Returns true if the input string ends in "_id"
-
- Method defined in:
- cake/libs/model/model.php on line 2662
- Return
boolean True if the field is a foreign key listed in the belongsTo array.
- Access
public
isUnique
topReturns false if any fields passed match any (by default, all if $or = false) of their matching values.
- Parameters:
-
-
array $fields required
Field/value pairs to search (if no values specified, they are pulled from $this->data)
-
boolean $or optional true
If false, all fields specified must match in order for a false return value
-
- Method defined in:
- cake/libs/model/model.php on line 2377
- Return
boolean False if any records matching any fields are found
- Access
public
isVirtualField
topReturns true if the supplied field is a model Virtual Field
- Parameters:
-
-
$field required
-
- Method defined in:
- cake/libs/model/model.php on line 1027
- Return
boolean indicating whether the field exists as a model virtual field.
- Access
public
joinModel
topGets the name and fields to be used by a join model. This allows specifying join fields in the association definition.
- Parameters:
-
-
$assoc required
-
array $keys optional array ( )
Any join keys which must be merged with the keys queried
-
- Method defined in:
- cake/libs/model/model.php on line 2875
- Return
array
- Access
public
log
topConvience method to write a message to CakeLog. See CakeLog::write() for more information on writing to logs.
- Parameters:
-
-
string $msg required
Log message
-
integer $type optional 2
Error type constant. Defined in app/config/core.php.
-
- Method defined in:
- cake/libs/object.php on line 148
- Return
boolean Success of log write
- Access
public
Object
topA 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:
- cake/libs/object.php on line 43
- Return
Object
onError
topCalled when a DataSource-level error occurs.
- Method defined in:
- cake/libs/model/model.php on line 2978
- Access
public
- Link
- http://book.cakephp.org/view/1048/Callback-Methods#onError-1056
__openPersistent
topOpen the persistent class file for reading Used by Object::_persist()
- Parameters:
-
-
string $name required
Name of persisted class
-
string $type optional NULL
Type of persistance (e.g: registry)
-
- Method defined in:
- cake/libs/object.php on line 268
- Return
void
- Access
private
overload
topOverload implementation. No need for implementation in PHP5.
- Method defined in:
- cake/libs/overloadable_php5.php on line 36
- Access
public
_persist
topChecks 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:
-
-
string $name required
name of the class to persist
-
$return required
-
string $object required
the object to persist
-
$type optional NULL
-
- Method defined in:
- cake/libs/object.php on line 218
- Return
boolean Success
- Access
protected
- Todo
add examples to manual
_prepareUpdateFields
topHelper method for Model::updateCounterCache(). Checks the fields to be updated for
- Parameters:
-
-
array $data required
The fields of the record that will be updated
-
- Method defined in:
- cake/libs/model/model.php on line 1528
- 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
topReturns a resultset for a given SQL statement. Custom SQL queries should be performed with this method.
- Method defined in:
- cake/libs/model/model.php on line 2420
- Return
array Resultset
- Access
public
- Link
- http://book.cakephp.org/view/1027/query
read
topReturns a list of fields from the database, and sets the current model data (Model::$data) with the record found.
- Parameters:
-
-
mixed $fields optional NULL
String of single fieldname, or an array of fieldnames.
-
mixed $id optional NULL
The ID of the record to read
-
- Method defined in:
- cake/libs/model/model.php on line 1108
- Return
array Array of database fields, or false if not found
- Access
public
- Link
- http://book.cakephp.org/view/1017/Retrieving-Your-Data#read-1029
requestAction
topCalls a controller's method from any location. Can be used to connect controllers together or tie plugins into a main application. requestAction can be used to return rendered views or fetch the return value from controller actions.
- Parameters:
-
-
mixed $url required
String or array-based url.
-
array $extra optional array ( )
if array includes the key "return" it sets the AutoRender to true.
-
- Method defined in:
- cake/libs/object.php on line 80
- Return
mixed Boolean true or false on success/failure, or contents of rendered action if 'return' is set in $extra.
- Access
public
resetAssociations
topCalled 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:
- cake/libs/model/model.php on line 2348
- Return
boolean Success
- Access
public
save
topSaves model data (based on white-list, if supplied) to the database. By default, validation occurs before save.
- Parameters:
-
-
array $data optional NULL
Data to save.
-
mixed $validate optional true
Either a boolean, or an array. If a boolean, indicates whether or not to validate before saving. If an array, allows control of validate, callbacks, and fieldList
-
array $fieldList optional array ( )
List of fields to allow to be written
-
- Method defined in:
- cake/libs/model/model.php on line 1209
- Return
mixed On success Model::$data if its not empty or true, false on failure
- Access
public
- Link
- http://book.cakephp.org/view/1031/Saving-Your-Data
__save
topPrivate helper method used by saveAll.
- Parameters:
-
-
$data required
-
$options required
-
- Method defined in:
- cake/libs/model/model.php on line 1754
- Return
boolean Success
- Access
private
- See
saveAll
topSaves multiple individual records for a single model; Also works with a single record, as well as all its associated records.
Options
- validate: Set to false to disable validation, true to validate each record before saving, 'first' to validate all records before any are saved (default), 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.
- fieldList: Equivalent to the $fieldList parameter in Model::save()
- Parameters:
-
-
array $data optional NULL
Record data to save. This can be either a numerically-indexed array (for saving multiple records of the same type), or an array indexed by association name.
-
array $options optional array ( )
Options to use when saving record data, See $options above.
-
- Method defined in:
- cake/libs/model/model.php on line 1571
- Return
mixed If atomic: True on success, or false on failure. Otherwise: array similar to the $data array passed, but values are set to true/false depending on whether each record saved successfully.
- Access
public
- Link
- Array
saveField
topSaves the value of a single field to the database, based on the current model ID.
- Parameters:
-
-
string $name required
Name of the table field
-
mixed $value required
Value of the field
-
array $validate optional false
See $options param in Model::save(). Does not respect 'fieldList' key if passed
-
- Method defined in:
- cake/libs/model/model.php on line 1184
- Return
boolean See Model::save()
- Access
public
- See
- Link
- http://book.cakephp.org/view/1031/Saving-Your-Data
__saveMulti
topSaves model hasAndBelongsToMany data to the database.
- Parameters:
-
-
array $joined required
Data to save
-
mixed $id required
ID of record in this model
-
$db required
-
- Method defined in:
- cake/libs/model/model.php on line 1380
- Access
private
_savePersistent
topYou should choose a unique name for the persistent file
There are many uses for this method, see manual for examples
- Parameters:
-
-
string $name required
name used for object to cache
-
object $object required
the object to persist
-
- Method defined in:
- cake/libs/object.php on line 247
- Return
boolean true on save, throws error if file can not be created
- Access
protected
schema
topReturns an array of table metadata (column names and types) from the database. $field => keys(type, null, default, key, length, extra)
- Parameters:
-
-
mixed $field optional false
Set to true to reload schema, or a string to return a specific field
-
- Method defined in:
- cake/libs/model/model.php on line 920
- Return
array Array of table metadata
- Access
public
set
topThis function does two things:
- 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.
- 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:
-
-
mixed $one required
Array or string of data
-
string $two optional NULL
Value string for the alternative indata method
-
- Method defined in:
- cake/libs/model/model.php on line 795
- Return
array Data with all of $one's keys and values
- Access
public
- Link
- http://book.cakephp.org/view/1031/Saving-Your-Data
_set
topAllows setting of multiple properties of the object in a single line of code. Will only set properties that are part of a class declaration.
- Parameters:
-
-
array $properties optional array ( )
An associative array containing properties and corresponding values.
-
- Method defined in:
- cake/libs/object.php on line 166
- Return
void
- Access
protected
setDataSource
topSets the DataSource to which this model is bound.
- Parameters:
-
-
string $dataSource optional NULL
The name of the DataSource, as defined in app/config/database.php
-
- Method defined in:
- cake/libs/model/model.php on line 2787
- Return
boolean True on success
- Access
public
setInsertID
topSets the ID of the last record this model inserted
- Parameters:
-
-
$id required
-
- Method defined in:
- cake/libs/model/model.php on line 2754
- Access
public
setSource
topSets a custom table for your controller class. Used by your controller to select a database table.
- Parameters:
-
-
string $tableName required
Name of the custom table
-
- Method defined in:
- cake/libs/model/model.php on line 759
- Return
void
- Access
public
__sleep
topCalled when serializing a model.
- Method defined in:
- cake/libs/model/model.php on line 3018
- Return
array Set of object variable names this model has
- Access
private
_stop
topStop execution of the current script. Wraps exit() making testing easier.
- Parameters:
-
-
$status optional 0
-
- Method defined in:
- cake/libs/object.php on line 135
- Return
void
- Access
public
toString
topObject-to-string conversion. Each class can override this method as necessary.
- Method defined in:
- cake/libs/object.php on line 64
- Return
string The name of this class
- Access
public
unbindModel
topTurn 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:
$this->User->unbindModel( array('hasMany' => array('Supportrequest')) );
unbound models that are not made permanent will reset with the next call to Model::find()
- Parameters:
-
-
array $params required
Set of bindings to unbind (indexed by binding type)
-
boolean $reset optional true
Set to false to make the unbinding permanent
-
- Method defined in:
- cake/libs/model/model.php on line 570
- Return
boolean Success
- Access
public
- Link
- http://book.cakephp.org/view/1045/Creating-and-Destroying-Associations-on-the-Fly
updateAll
topUpdates multiple model records based on a set of conditions.
- Parameters:
-
-
array $fields required
Set of fields and values, indexed by fields. Fields are treated as SQL snippets, to insert literal values manually escape your data.
-
mixed $conditions optional true
Conditions to match, true for all records
-
- Method defined in:
- cake/libs/model/model.php on line 1775
- Return
boolean True on success, false on failure
- Access
public
- Link
- http://book.cakephp.org/view/1031/Saving-Your-Data
updateCounterCache
topUpdates the counter cache of belongsTo associations after a save or delete operation
- Parameters:
-
-
array $keys optional array ( )
Optional foreign key data, defaults to the information $this->data
-
boolean $created optional false
True if a new record was created, otherwise only associations with 'counterScope' defined get updated
-
- Method defined in:
- cake/libs/model/model.php on line 1472
- Return
void
- Access
public
validates
topReturns true if all fields pass validation. Will validate hasAndBelongsToMany associations that use the 'with' key as well. Since __saveMulti is incapable of exiting a save operation.
Will validate the currently set data. Use Model::set() or Model::create() to set the active data.
- Parameters:
-
-
string $options optional array ( )
An optional array of custom options to be made available in the beforeValidate callback
-
- Method defined in:
- cake/libs/model/model.php on line 2437
- Return
boolean True if there are no errors
- Access
public
- Link
- http://book.cakephp.org/view/1182/Validating-Data-from-the-Controller
__validateWithModels
topRuns validation for hasAndBelongsToMany associations that have 'with' keys set. And data in the set() data set.
- Parameters:
-
-
array $options required
Array of options to use on Valdation of with models
-
- Method defined in:
- cake/libs/model/model.php on line 2611
- Return
boolean Failure of validation on with models.
- Access
private
- See
__wakeup
topCalled when de-serializing a model.
- Method defined in:
- cake/libs/model/model.php on line 3029
- Access
private
- Todo
