DataSource Class Info:
- Class Declaration:
class DataSource extends Object
- File name:
- cake/libs/model/datasources/datasource.php
- Description:
DataSource base class
- Class Inheritance
- Package
- cake
- Subpackage
- cake.cake.libs.model.datasources
Properties:
-
affected string
String to hold how many rows were affected by the last SQL operation.
-
_baseConfig array
The default configuration of a specific DataSource
-
cacheSources boolean
Whether or not source data like available tables and schema descriptions should be cached
-
config array
The DataSource configuration
-
configKeyName string
The DataSource configuration key name
-
connected boolean
Are we connected to the DataSource?
-
connection array
A reference to the physical connection of this DataSource
-
endQuote string
The ending character that this DataSource uses for quoted identifiers.
-
error unknown_type
Error description of last query
-
fullDebug boolean
Print full query debug info?
-
numRows int
Number of rows in current resultset
-
_queriesCnt int
Queries count.
-
_queriesLog unknown_type
Log of queries executed by this DataSource
-
_queriesLogMax int Maximum number of queries in the queries log.
Maximum number of items in query log
This is to prevent query log taking over too much memory.
-
_queriesTime unknown_type
Total duration of all queries.
-
_queryCache array Maximum number of queries in the queries log.
Caches serialzed results of executed queries
-
_result array
Result
-
_sources array
Holds a list of sources (tables) contained in the DataSource
-
startQuote string
The starting character that this DataSource uses for quoted identifiers.
-
took int
Time the last query took
-
_transactionStarted boolean
Whether or not this DataSource is in the middle of a transaction
Method Summary:
- begin( $model )
- cakeError( $method, $messages = array ( ) )
- column( $real )
- commit( $model )
- __construct( $config = array ( ) )
- create( $model, $fields = NULL, $values = NULL )
- delete( $model, $id = NULL )
- describe( $model )
- __destruct( )
- dispatchMethod( $method, $params = array ( ) )
- enabled( )
- insertQueryData( $query, $data, $association, $assocData, $model, $linkModel, $stack )
- isInterfaceSupported( $interface )
- lastAffected( $source = NULL )
- lastInsertId( $source = NULL )
- lastNumRows( $source = NULL )
- listSources( $data = NULL )
- log( $msg, $type = 2 )
- Object( )
- _persist( $name, $return, $object, $type = NULL )
- read( $model, $queryData = array ( ) )
- requestAction( $url, $extra = array ( ) )
- resolveKey( $model, $key )
- rollback( $model )
- _savePersistent( $name, $object )
- _set( $properties = array ( ) )
- setConfig( $config = array ( ) )
- sources( $reset = false )
- _stop( $status = 0 )
- toString( )
- update( $model, $fields = NULL, $values = NULL )
begin
topBegin a transaction
- Parameters:
-
-
$model required
-
- Method defined in:
- cake/libs/model/datasources/datasource.php on line 293
- Return
boolean Returns true if a transaction is not in progress
- Access
public
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
column
topConverts column types to basic types
- Parameters:
-
-
string $real required
Real column type (i.e. "varchar(255)")
-
- Method defined in:
- cake/libs/model/datasources/datasource.php on line 324
- Return
string Abstract column type (i.e. "string")
- Access
public
commit
topCommit a transaction
- Parameters:
-
-
$model required
-
- Method defined in:
- cake/libs/model/datasources/datasource.php on line 303
- Return
boolean Returns true if a transaction is in progress
- Access
public
__construct
topConstructor.
- Parameters:
-
-
array $config optional array ( )
Array of configuration information for the datasource.
-
- Method defined in:
- cake/libs/model/datasources/datasource.php on line 214
- Return
void.
create
topUsed to create new records. The "C" CRUD.
To-be-overridden in subclasses.
- Parameters:
-
-
Model $model required
The Model to be created.
-
array $fields optional NULL
An Array of fields to be saved.
-
array $values optional NULL
An Array of values to save.
-
- Method defined in:
- cake/libs/model/datasources/datasource.php on line 339
- Return
boolean success
- Access
public
delete
topDelete a record(s) in the datasource.
To-be-overridden in subclasses.
- Parameters:
-
-
Model $model required
The model class having record(s) deleted
-
mixed $id optional NULL
Primary key of the model
-
- Method defined in:
- cake/libs/model/datasources/datasource.php on line 381
- Access
public
describe
topReturns a Model description (metadata) or null if none found.
- Parameters:
-
-
Model $model required
-
- Method defined in:
- cake/libs/model/datasources/datasource.php on line 269
- Return
array Array of Metadata for the $model
- Access
public
__destruct
topCloses the current datasource.
- Method defined in:
- cake/libs/model/datasources/datasource.php on line 592
- Return
void
- Access
public
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
enabled
topCheck whether the conditions for the Datasource being available are satisfied. Often used from connect() to check for support before establishing a connection.
- Method defined in:
- cake/libs/model/datasources/datasource.php on line 428
- Return
boolean Whether or not the Datasources conditions for use are met.
- Access
public
insertQueryData
topReplaces {$cakeID$} and {$cakeForeignKey$} placeholders in query data.
- Parameters:
-
-
string $query required
Query string needing replacements done.
-
array $data required
Array of data with values that will be inserted in placeholders.
-
string $association required
Name of association model being replaced
-
unknown_type $assocData required
Name of association model being replaced
-
Model $model required
Instance of the model to replace $cakeID$
-
Model $linkModel required
Instance of model to replace $cakeForeignKey$
-
array $stack required
Instance of model to replace $cakeForeignKey$
-
- Method defined in:
- cake/libs/model/datasources/datasource.php on line 501
- Return
string String of query data with placeholders replaced.
- Access
public
- Todo
Remove and refactor $assocData, ensure uses of the method have the param removed too.
isInterfaceSupported
topReturns true if the DataSource supports the given interface (method)
- Parameters:
-
-
string $interface required
The name of the interface (method)
-
- Method defined in:
- cake/libs/model/datasources/datasource.php on line 439
- Return
boolean True on success
- Access
public
lastAffected
topReturns the number of rows affected by last query.
- Parameters:
-
-
unknown_type $source optional NULL
-
- Method defined in:
- cake/libs/model/datasources/datasource.php on line 416
- Return
integer Number of rows affected by last query.
- Access
public
lastInsertId
topReturns the ID generated from the previous INSERT operation.
- Parameters:
-
-
unknown_type $source optional NULL
-
- Method defined in:
- cake/libs/model/datasources/datasource.php on line 394
- Return
mixed Last ID key generated in previous INSERT
- Access
public
lastNumRows
topReturns the number of rows returned by last operation.
- Parameters:
-
-
unknown_type $source optional NULL
-
- Method defined in:
- cake/libs/model/datasources/datasource.php on line 405
- Return
integer Number of rows returned by last operation
- Access
public
listSources
topCaches/returns cached results for child instances
- Parameters:
-
-
mixed $data optional NULL
-
- Method defined in:
- cake/libs/model/datasources/datasource.php on line 226
- Return
array Array of sources available in this datasource.
- 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
_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
read
topUsed to read records from the Datasource. The "R" in CRUD
To-be-overridden in subclasses.
- Parameters:
-
-
Model $model required
The model being read.
-
array $queryData optional array ( )
An array of query data used to find the data you want
-
- Method defined in:
- cake/libs/model/datasources/datasource.php on line 353
- Return
mixed
- Access
public
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
resolveKey
topTo-be-overridden in subclasses.
- Parameters:
-
-
Model $model required
Model instance
-
string $key required
Key name to make
-
- Method defined in:
- cake/libs/model/datasources/datasource.php on line 582
- Return
string Key name for model.
- Access
public
rollback
topRollback a transaction
- Parameters:
-
-
$model required
-
- Method defined in:
- cake/libs/model/datasources/datasource.php on line 313
- Return
boolean Returns true if a transaction is in progress
- Access
public
_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
_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
setConfig
topSets the configuration for the DataSource. Merges the $config information with the _baseConfig and the existing $config property.
- Parameters:
-
-
array $config optional array ( )
The configuration array
-
- Method defined in:
- cake/libs/model/datasources/datasource.php on line 455
- Return
void
- Access
public
sources
topConvenience method for DboSource::listSources(). Returns source names in lowercase.
- Parameters:
-
-
boolean $reset optional false
Whether or not the source list should be reset.
-
- Method defined in:
- cake/libs/model/datasources/datasource.php on line 255
- Return
array Array of sources available in this datasource
- Access
public
_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
update
topUpdate a record(s) in the datasource.
To-be-overridden in subclasses.
- Parameters:
-
-
Model $model required
Instance of the model class being updated
-
array $fields optional NULL
Array of fields to be updated
-
array $values optional NULL
Array of values to be update $fields to.
-
- Method defined in:
- cake/libs/model/datasources/datasource.php on line 368
- Return
boolean Success
- Access
public