DataSource base class
DataSources are the link between models and the source of data that models represent.
DataSource __construct( array $config array() )
Constructor.
$config optional array() Object::__construct() _cacheDescription( string $object , mixed $data null )
Cache the DataSource description
$object $data optional null mixedbegin( )
Begin a transaction
booleancolumn( string $real )
Converts column types to basic types
$real stringcommit( )
Commit a transaction
booleancreate( Model $Model , array $fields null , array $values null )
Used to create new records. The "C" CRUD.
To-be-overridden in subclasses.
Model $Model $fields optional null $values optional null booleandelete( Model $Model , mixed $conditions null )
Delete a record(s) in the datasource.
To-be-overridden in subclasses.
Model $Model $conditions optional null booleandescribe( Model|string $model )
Returns a Model description (metadata) or null if none found.
Model|string $model array|nullenabled( )
Check whether the conditions for the Datasource being available are satisfied. Often used from connect() to check for support before establishing a connection.
booleangetSchemaName( )
Returns the schema name. Override this in subclasses.
string|nullinsertQueryData( string $query , array $data , string $association , Model $Model , array $stack )
Replaces {$__cakeID__$} and {$__cakeForeignKey__$} placeholders in query data.
$query $data $association Model $Model $stack mixedlastAffected( mixed $source null )
Returns the number of rows affected by last query.
$source optional null integerlastInsertId( mixed $source null )
Returns the ID generated from the previous INSERT operation.
$source optional null mixedlastNumRows( mixed $source null )
Returns the number of rows returned by last operation.
$source optional null integerlistSources( mixed $data null )
Caches/returns cached results for child instances
$data optional null array|nullread( Model $Model , array $queryData array() , integer $recursive null )
Used to read records from the Datasource. The "R" in CRUD
To-be-overridden in subclasses.
Model $Model $queryData optional array() $recursive optional null mixedresolveKey( Model $Model , string $key )
To-be-overridden in subclasses.
Model $Model $key stringrollback( )
Rollback a transaction
booleansetConfig( array $config array() )
Sets the configuration for the DataSource. Merges the $config information with the _baseConfig and the existing $config property.
$config optional array() update( Model $Model , array $fields null , array $values null , mixed $conditions null )
Update a record(s) in the datasource.
To-be-overridden in subclasses.
Model $Model $fields optional null $values optional null $conditions optional null boolean_mergeVars( array $properties , string $class , boolean $normalize true )
Merges this objects $property with the property in $class' definition. This classes value for the property will be merged on top of $class'
This provides some of the DRY magic CakePHP provides. If you want to shut it off, redefine this method as an empty function.
$properties $class $normalize optional true _set( array $properties array() )
Allows setting of multiple properties of the object in a single line of code. Will only set properties that are part of a class declaration.
$properties optional array() _stop( integer|string $status 0 )
Stop execution of the current script. Wraps exit() making testing easier.
$status optional 0 dispatchMethod( string $method , array $params array() )
Calls a method on this object with the given parameters. Provides an OO wrapper for call_user_func_array
$method $params optional array() mixedlog( string $msg , integer $type LOG_ERR , null|string|array $scope null )
Convenience method to write a message to CakeLog. See CakeLog::write() for more information on writing to logs.
$msg $type optional LOG_ERR $scope optional null booleanrequestAction( string|array $url , array $extra array() )
Calls 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.
Under the hood this method uses Router::reverse() to convert the $url parameter into a string URL. You should use URL formats that are compatible with Router::reverse()
POST and GET data can be simulated in requestAction. Use $extra['url'] for GET data. The $extra['data'] parameter allows POST data simulation.
$url $extra optional array() mixedtoString( )
Object-to-string conversion. Each class can override this method as necessary.
string
© 2005–2016 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
http://api.cakephp.org/2.7/class-DataSource.html