DataSource base class
DataSources are the link between models and the source of data that models represent.
DataSource $_baseConfig protected array$_descriptions protected array$_sources protected array$_transactionStarted protected boolean$cacheSources public booleanWhether or not source data like available tables and schema descriptions should be cached
$config public array$connected public booleanCheck whether the conditions for the Datasource being available are satisfied. Often used from connect() to check for support before establishing a connection.
{$__cakeID__$} and {$__cakeForeignKey__$} placeholders in query data. Sets the configuration for the DataSource. Merges the $config information with the _baseConfig and the existing $config property.
__construct( array $config array() )
Constructor.
$config optional array() Object::__construct() _cacheDescription( string $object , mixed $data null )
Cache the DataSource description
$object $data optional null begin( )
Begin a transaction
column( string $real )
Converts column types to basic types
$real commit( )
Commit a transaction
create( 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 delete( Model $Model , mixed $conditions null )
Delete a record(s) in the datasource.
To-be-overridden in subclasses.
Model $Model $conditions optional null describe( Model|string $model )
Returns a Model description (metadata) or null if none found.
Model|string $model enabled( )
Check whether the conditions for the Datasource being available are satisfied. Often used from connect() to check for support before establishing a connection.
getSchemaName( )
Returns the schema name. Override this in subclasses.
insertQueryData( string $query , array $data , string $association , Model $Model , array $stack )
Replaces {$__cakeID__$} and {$__cakeForeignKey__$} placeholders in query data.
$query $data $association Model $Model $stack lastAffected( mixed $source null )
Returns the number of rows affected by last query.
$source optional null lastInsertId( mixed $source null )
Returns the ID generated from the previous INSERT operation.
$source optional null lastNumRows( mixed $source null )
Returns the number of rows returned by last operation.
$source optional null listSources( mixed $data null )
Caches/returns cached results for child instances
$data optional null read( 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 resolveKey( Model $Model , string $key )
To-be-overridden in subclasses.
Model $Model $key rollback( )
Rollback a transaction
setConfig( 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 _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() log( 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 The scope(s) a log message is being created in. See CakeLog::config() for more information on logging scopes.
requestAction( 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 String or array-based URL. Unlike other URL arrays in CakePHP, this URL will not automatically handle passed and named arguments in the $url parameter.
$extra optional array() if array includes the key "return" it sets the AutoRender to true. Can also be used to submit GET/POST data, and named/passed arguments.
Boolean true or false on success/failure, or contents of rendered action if 'return' is set in $extra.
toString( )
Object-to-string conversion. Each class can override this method as necessary.
protected array
Holds references to descriptions loaded by the DataSource
array()
protected boolean
Whether or not this DataSource is in the middle of a transaction
false
public boolean
Whether or not source data like available tables and schema descriptions should be cached
true
© 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.8/class-DataSource.html