DataSource base class
DataSources are the link between models and the source of data that models represent.
__construct( array $config array() )
Constructor.
$config
optional array() Object::__construct()
_cacheDescription( string $object , mixed $data null )
Cache the DataSource description
$object
$data
optional null mixed
begin( )
Begin a transaction
boolean
column( string $real )
Converts column types to basic types
$real
string
commit( )
Commit a transaction
boolean
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 boolean
delete( Model $Model , mixed $conditions null )
Delete a record(s) in the datasource.
To-be-overridden in subclasses.
Model
$Model
$conditions
optional null boolean
describe( Model|string $model )
Returns a Model description (metadata) or null if none found.
Model
|string $model
array|null
enabled( )
Check whether the conditions for the Datasource being available are satisfied. Often used from connect() to check for support before establishing a connection.
boolean
getSchemaName( )
Returns the schema name. Override this in subclasses.
string|null
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
mixed
lastAffected( mixed $source null )
Returns the number of rows affected by last query.
$source
optional null integer
lastInsertId( mixed $source null )
Returns the ID generated from the previous INSERT operation.
$source
optional null mixed
lastNumRows( mixed $source null )
Returns the number of rows returned by last operation.
$source
optional null integer
listSources( mixed $data null )
Caches/returns cached results for child instances
$data
optional null array|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 mixed
resolveKey( Model $Model , string $key )
To-be-overridden in subclasses.
Model
$Model
$key
string
rollback( )
Rollback a transaction
boolean
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 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() mixed
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 boolean
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
$extra
optional array() mixed
toString( )
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