DboMysql Class Info:
- Class Declaration:
class DboMysql extends DboMysqlBase
- File name:
- cake/libs/model/datasources/dbo/dbo_mysql.php
- Description:
MySQL DBO driver object
Provides connection and SQL generation for MySQL RDMS
- Class Inheritance
- Package
- cake
- Subpackage
- cake.cake.libs.model.datasources.dbo
Properties:
-
affected string
String to hold how many rows were affected by the last SQL operation.
-
alias string
Database keyword used to assign aliases to identifiers.
-
_baseConfig array
Base configuration settings for MySQL driver
-
cacheMethods boolean.
Whether or not to cache the results of DboSource::name() and DboSource::conditions() into the memory cache. Set to false to disable the use of the memory cache.
-
cacheSources boolean
Whether or not source data like available tables and schema descriptions should be cached
-
columns array
MySQL column definition
-
_commands array
Index of basic SQL commands
-
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
-
description string
Datasource description
-
endQuote string
End quote
-
error unknown_type
Error description of last query
-
fieldParameters array
List of engine specific additional field parameters used on table creating
-
fullDebug boolean
Print full query debug info?
-
index array
index definition, standard cake, primary, index, unique
-
methodCache array
Caches result from query parsing operations. Cached results for both DboSource::name() and DboSource::conditions() will be stored here. Method caching uses
crc32()which is fast but can collisions more easily than other hashing algorithms. If you have problems with collisions, set DboSource::$cacheMethods to false. -
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
Start quote
-
tableParameters array
List of table engine specific parameters used on table creating
-
took int
Time the last query took
-
_transactionStarted boolean
Whether or not this DataSource is in the middle of a transaction
-
_useAlias boolean
use alias for update and delete. Set to true if version >= 4.1
-
virtualFieldSeparator string
Separator string for virtualField composition
Method Summary:
- _alterIndexes( $table, $indexes )
- alterSchema( $compare, $table = NULL )
- _alterTableParameters( $table, $parameters )
- begin( $model )
- boolean( $data )
- buildColumn( $column )
- _buildFieldParameters( $columnString, $columnData, $position )
- buildIndex( $indexes, $table = NULL )
- buildJoinStatement( $join )
- buildStatement( $query, $model )
- buildTableParameters( $parameters, $table = NULL )
- cacheMethod( $method, $key, $value = NULL )
- cakeError( $method, $messages = array ( ) )
- calculate( $model, $func, $params = array ( ) )
- close( )
- column( $real )
- commit( $model )
- conditionKeysToString( $conditions, $quoteValues = true, $model = NULL )
- conditions( $conditions, $quoteValues = true, $where = true, $model = NULL )
- connect( )
- __construct( $config = NULL, $autoConnect = true )
- _constructVirtualFields( $model, $alias, $fields )
- create( $model, $fields = NULL, $values = NULL )
- createSchema( $schema, $tableName = NULL )
- defaultConditions( $model, $conditions, $useAlias = true )
- delete( $model, $conditions = NULL )
- describe( $model )
- __destruct( )
- disconnect( )
- dispatchMethod( $method, $params = array ( ) )
- dropSchema( $schema, $table = NULL )
- enabled( )
- _execute( $sql )
- execute( $sql, $options = array ( ) )
- expression( $expression )
- fetchAll( $sql, $cache = true, $modelName = NULL )
- fetchAssociated( $model, $query, $ids )
- fetchResult( )
- fetchRow( $sql = NULL )
- fetchVirtualField( $result )
- field( $name, $sql )
- fields( $model, $alias = NULL, $fields = array ( ), $quote = true )
- flushMethodCache( )
- fullTableName( $model, $quote = true )
- generateAssociationQuery( $model, $linkModel, $type, $association, $assocData, $queryData, $external, $resultSet )
- getCharsetName( $name )
- getConstraint( $type, $model, $linkModel, $alias, $assoc, $alias2 = NULL )
- getEncoding( )
- _getJoins( $model )
- getLog( $sorted = false, $clear = true )
- group( $group, $model = NULL )
- hasAny( $Model, $sql )
- hasResult( )
- identifier( $identifier )
- index( $model )
- insertMulti( $table, $fields, $values )
- insertQueryData( $query, $data, $association, $assocData, $model, $linkModel, $stack )
- introspectType( $value )
- isConnected( )
- isInterfaceSupported( $interface )
- lastAffected( )
- lastError( )
- lastInsertId( $source = NULL )
- lastNumRows( )
- length( $real )
- limit( $limit, $offset = NULL )
- listDetailedSources( $name = NULL )
- listSources( )
- log( $msg, $type = 2 )
- logQuery( $sql )
- _matchRecords( $model, $conditions = NULL )
- __mergeHasMany( $resultSet, $merge, $association, $model, $linkModel )
- name( $data )
- Object( )
- order( $keys, $direction = 'ASC', $model = NULL )
- _persist( $name, $return, $object, $type = NULL )
- _prepareUpdateFields( $model, $fields, $quoteValues = true, $alias = false )
- query( )
- queryAssociation( $model, $linkModel, $type, $association, $assocData, $queryData, $external, $resultSet, $recursive, $stack )
- rawQuery( $sql )
- read( $model, $queryData = array ( ), $recursive = NULL )
- readTableParameters( $name )
- reconnect( $config = array ( ) )
- renderJoinStatement( $data )
- renderStatement( $type, $data )
- requestAction( $url, $extra = array ( ) )
- resolveKey( $model, $key, $assoc = NULL )
- resultSet( $results )
- rollback( $model )
- _savePersistent( $name, $object )
- __scrubQueryData( $data )
- _set( $properties = array ( ) )
- setConfig( $config = array ( ) )
- setEncoding( $enc )
- showLog( $sorted = false )
- showQuery( $sql )
- sources( $reset = false )
- _stop( $status = 0 )
- toString( )
- truncate( $table )
- update( $model, $fields = array ( ), $values = NULL, $conditions = NULL )
- value( $data, $column = NULL, $safe = false )
_alterIndexes
topGenerate MySQL index alteration statements for a table.
- Parameters:
-
-
string $table required
Table to alter indexes for
-
$indexes required
-
- Method defined in:
- cake/libs/model/datasources/dbo/dbo_mysql.php on line 389
- Return
array Index alteration statements
alterSchema
topGenerate a MySQL Alter Table syntax for the given Schema comparison
- Parameters:
-
-
array $compare required
Result of a CakeSchema::compare()
-
$table optional NULL
-
- Method defined in:
- cake/libs/model/datasources/dbo/dbo_mysql.php on line 291
- Return
array Array of alter statements to make.
_alterTableParameters
topGenerate MySQL table parameter alteration statementes for a table.
- Parameters:
-
-
string $table required
Table to alter parameters for.
-
array $parameters required
Parameters to add & drop.
-
- Method defined in:
- cake/libs/model/datasources/dbo/dbo_mysql.php on line 375
- Return
array Array of table property alteration statementes.
- Todo
Implement this method.
begin
topBegin a transaction
(i.e. if the database/model does not support transactions, or a transaction has not started).
- Parameters:
-
-
model $model required
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 1808
- Return
boolean True on success, false on fail
- Access
public
boolean
topTranslates between PHP boolean values and Database (faked) boolean values
- Parameters:
-
-
mixed $data required
Value to be translated
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 2580
- Return
mixed Converted boolean value
- Access
public
buildColumn
topGenerate a database-native column schema string
- Parameters:
-
-
array $column required
An array structured like the following: array('name'=>'value', 'type'=>'value'[, options]), where options can be 'default', 'length', or 'key'.
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 2715
- Return
string
- Access
public
_buildFieldParameters
topBuild the field parameters, in a position
- Parameters:
-
-
string $columnString required
The partially built column string
-
array $columnData required
The array of column data.
-
string $position required
The position type to use. 'beforeDefault' or 'afterDefault' are common
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 2781
- Return
string a built column with the field parameters added.
- Access
public
buildIndex
topFormat indexes for create table
- Parameters:
-
-
array $indexes required
-
string $table optional NULL
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 2805
- Return
array
- Access
public
buildJoinStatement
topBuilds and generates a JOIN statement from an array. Handles final clean-up before conversion.
- Parameters:
-
-
array $join required
An array defining a JOIN statement in a query
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 1425
- Return
string An SQL JOIN statement to be used in a query
- Access
public
- See
buildStatement
topBuilds and generates an SQL statement from an array. Handles final clean-up before conversion.
- Parameters:
-
-
array $query required
An array defining an SQL query
-
object $model required
The model object which initiated the query
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 1451
- Return
string An executable SQL statement
- Access
public
- See
buildTableParameters
topFormat parameters for create table
- Parameters:
-
-
array $parameters required
-
string $table optional NULL
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 2857
- Return
array
- Access
public
cacheMethod
topCache a value into the methodCaches. Will respect the value of DboSource::$cacheMethods. Will retrieve a value from the cache if $value is null.
If caching is disabled and a write is attempted, the $value will be returned. A read will either return the value or null.
- Parameters:
-
-
string $method required
Name of the method being cached.
-
string $key required
The keyname for the cache operation.
-
mixed $value optional NULL
The value to cache into memory.
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 504
- Return
mixed Either null on failure, or the value if its set.
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
calculate
topReturns an SQL calculation, i.e. COUNT() or MAX()
- Parameters:
-
-
model $model required
-
string $func required
Lowercase name of SQL function, i.e. 'count' or 'max'
-
array $params optional array ( )
Function parameters (any values must be quoted manually)
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 1755
- Return
string An SQL calculation function
- Access
public
close
topDisconnects database, kills the connection and says the connection is closed.
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 2485
- Return
void
- Access
public
column
topConverts database-layer column types to basic types
- Parameters:
-
-
string $real required
Real database-layer column type (i.e. "varchar(255)")
-
- Method defined in:
- cake/libs/model/datasources/dbo/dbo_mysql.php on line 477
- Return
string Abstract column type (i.e. "string")
commit
topCommit a transaction
(i.e. if the database/model does not support transactions, or a transaction has not started).
- Parameters:
-
-
model $model required
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 1825
- Return
boolean True on success, false on fail
- Access
public
conditionKeysToString
topCreates a WHERE clause by parsing given conditions array. Used by DboSource::conditions().
- Parameters:
-
-
array $conditions required
Array or string of conditions
-
boolean $quoteValues optional true
If true, values should be quoted
-
Model $model optional NULL
A reference to the Model instance making the query
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 2134
- Return
string SQL fragment
- Access
public
conditions
topCreates a WHERE clause by parsing given conditions data. If an array or string conditions are provided those conditions will be parsed and quoted. If a boolean is given it will be integer cast as condition. Null will return 1 = 1.
Results of this method are stored in a memory cache. This improves performance, but because the method uses a simple hashing algorithm it can infrequently have collisions. Setting DboSource::$cacheMethods to false will disable the memory cache.
- Parameters:
-
-
mixed $conditions required
Array or string of conditions, or any value.
-
boolean $quoteValues optional true
If true, values should be quoted
-
boolean $where optional true
If true, "WHERE " will be prepended to the return value
-
Model $model optional NULL
A reference to the Model instance making the query
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 2071
- Return
string SQL fragment
- Access
public
connect
topConnects to the database using options in the given configuration array.
- Method defined in:
- cake/libs/model/datasources/dbo/dbo_mysql.php on line 556
- Return
boolean True if the database could be connected, else false
__construct
topConstructor
- Parameters:
-
-
array $config optional NULL
Array of configuration information for the Datasource.
-
boolean $autoConnect optional true
Whether or not the datasource should automatically connect.
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 133
- Access
public
_constructVirtualFields
topConverts model virtual fields into sql expressions to be fetched later
- Parameters:
-
-
Model $model required
-
string $alias required
Alias tablename
-
mixed $fields required
virtual fields to be used on query
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 1926
- Return
array
create
topThe "C" in CRUD
Creates new records in the database.
- Parameters:
-
-
Model $model required
Model object that the record is for.
-
array $fields optional NULL
An array of field names to insert. If null, $model->data will be used to generate field names.
-
array $values optional NULL
An array of values with keys matching the fields. If null, $model->data will be used to generate values.
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 727
- Return
boolean Success
- Access
public
createSchema
topGenerate a database-native schema for the given Schema object
- Parameters:
-
-
object $schema required
An instance of a subclass of CakeSchema
-
string $tableName optional NULL
Optional. If specified only the table name given will be generated. Otherwise, all tables defined in the schema are generated.
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 2630
- Return
string
- Access
public
defaultConditions
topCreates a default set of conditions from the model if $conditions is null/empty. If conditions are supplied then they will be returned. If a model doesn't exist and no conditions were provided either null or false will be returned based on what was input.
- Parameters:
-
-
object $model required
-
mixed $conditions required
Array of conditions, conditions string, null or false. If an array of conditions, or string conditions those conditions will be returned. With other values the model's existance will be checked. If the model doesn't exist a null or false will be returned depending on the input value.
-
boolean $useAlias optional true
Use model aliases rather than table names when generating conditions
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 1865
- Return
mixed Either null, false, $conditions or an array of default conditions to use.
- See
- Access
public
delete
topGenerates and executes an SQL DELETE statement for given id/conditions on given model.
- Parameters:
-
-
Model $model required
-
mixed $conditions optional NULL
-
- Method defined in:
- cake/libs/model/datasources/dbo/dbo_mysql.php on line 210
- Return
boolean Success
describe
topReturns an array of the fields in given table name.
- Parameters:
-
-
$model required
-
- Method defined in:
- cake/libs/model/datasources/dbo/dbo_mysql.php on line 119
- Return
array Fields in table. Keys are name and type
__destruct
topCloses the current datasource.
- Method defined in:
- cake/libs/model/datasources/datasource.php on line 592
- Return
void
- Access
public
disconnect
topDisconnects from database.
- Method defined in:
- cake/libs/model/datasources/dbo/dbo_mysql.php on line 593
- Return
boolean True if the database could be disconnected, else false
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
dropSchema
topGenerate a MySQL "drop table" statement for the given Schema object
- Parameters:
-
-
object $schema required
An instance of a subclass of CakeSchema
-
string $table optional NULL
Optional. If specified only the table name given will be generated. Otherwise, all tables defined in the schema are generated.
-
- Method defined in:
- cake/libs/model/datasources/dbo/dbo_mysql.php on line 353
- Return
string
enabled
topCheck whether the MySQL extension is installed/loaded
- Method defined in:
- cake/libs/model/datasources/dbo/dbo_mysql.php on line 585
- Return
boolean
_execute
topExecutes given SQL statement.
- Parameters:
-
-
string $sql required
SQL statement
-
- Method defined in:
- cake/libs/model/datasources/dbo/dbo_mysql.php on line 608
- Return
resource Result resource identifier
- Access
protected
execute
topQueries the database with given SQL statement, and obtains some metadata about the result (rows affected, timing, any errors, number of rows in resultset). The query is also logged. If Configure::read('debug') is set, the log is shown all the time, else it is only shown on errors.
Options
- stats - Collect meta data stats for this query. Stats include time take, rows affected,
any errors, and number of rows returned. Defaults to
true. - log - Whether or not the query should be logged to the memory log.
- Parameters:
-
-
string $sql required
-
array $options optional array ( )
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 248
- Return
mixed Resource or object representing the result set, or false on failure
- Access
public
expression
topReturns an object to represent a database expression in a query
- Parameters:
-
-
string $expression required
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 213
- Return
object An object representing a database expression to be used in a query
- Access
public
fetchAll
topReturns an array of all result rows for a given SQL query. Returns false if no rows matched.
- Parameters:
-
-
string $sql required
SQL statement
-
boolean $cache optional true
Enables returning/storing cached query results
-
$modelName optional NULL
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 403
- Return
array Array of resultset rows, or false if no rows matched
- Access
public
fetchAssociated
topA more efficient way to fetch associations. Woohoo!
- Parameters:
-
-
model $model required
Primary model object
-
string $query required
Association query
-
array $ids required
Array of IDs of associated records
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 1075
- Return
array Association results
- Access
public
fetchResult
topFetches the next row from the current result set
- Method defined in:
- cake/libs/model/datasources/dbo/dbo_mysql.php on line 769
- Return
unknown
fetchRow
topReturns a row from current resultset as an array
- Parameters:
-
-
$sql optional NULL
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 375
- Return
array The fetched row as an array
- Access
public
fetchVirtualField
topModifies $result array to place virtual fields in model entry where they belongs to
- Parameters:
-
-
$result required
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 442
- Return
void
field
topReturns a single field of the first of query results for a given SQL query, or false if empty.
- Parameters:
-
-
string $name required
Name of the field
-
string $sql required
SQL query
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 473
- Return
mixed Value of field read.
- Access
public
fields
topGenerates the fields list of an SQL query.
- Parameters:
-
-
Model $model required
-
string $alias optional NULL
Alias tablename
-
mixed $fields optional array ( )
Alias tablename
-
boolean $quote optional true
If false, returns fields array unquoted
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 1946
- Return
array
- Access
public
flushMethodCache
topEmpties the method caches. These caches are used by DboSource::name() and DboSource::conditions()
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 488
- Return
void
fullTableName
topGets full table name including prefix
- Parameters:
-
-
mixed $model required
Either a Model object or a string table name.
-
boolean $quote optional true
Whether you want the table name quoted.
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 700
- Return
string Full quoted table name
- Access
public
generateAssociationQuery
topGenerates an array representing a query or part of a query from a single model or two associated models
- Parameters:
-
-
Model $model required
-
Model $linkModel required
-
string $type required
-
string $association required
-
array $assocData required
-
array $queryData required
-
boolean $external required
-
array $resultSet required
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 1217
- Return
mixed
- Access
public
getCharsetName
topQuery charset by collation
- Parameters:
-
-
string $name required
Collation name
-
- Method defined in:
- cake/libs/model/datasources/dbo/dbo_mysql.php on line 799
- Return
string Character set name
getConstraint
topReturns a conditions array for the constraint between two models
- Parameters:
-
-
string $type required
Association type
-
object $model required
Model object
-
$linkModel required
-
$alias required
-
$assoc required
-
$alias2 optional NULL
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 1383
- Return
array Conditions array defining the constraint between $model and $association
- Access
public
getEncoding
topGets the database encoding
- Method defined in:
- cake/libs/model/datasources/dbo/dbo_mysql.php on line 789
- Return
string The database encoding
_getJoins
topReturns an array of SQL JOIN fragments from a model's associations
- Parameters:
-
-
object $model required
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 1725
- Return
array
- Access
protected
getLog
topGet the query log as an array.
- Parameters:
-
-
boolean $sorted optional false
Get the queries sorted by time taken, defaults to false.
-
$clear optional true
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 607
- Return
array Array of queries run as an array
- Access
public
group
topCreate a GROUP BY SQL clause
- Parameters:
-
-
string $group required
Group By Condition
-
$model optional NULL
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 2463
- Return
mixed string condition or null
- Access
public
hasAny
topChecks if the specified table contains any record matching specified SQL
- Parameters:
-
-
$Model required
-
string $sql required
SQL WHERE clause (condition only, not the "WHERE" part)
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 2497
- Return
boolean True if the table has a matching record, else false
- Access
public
hasResult
topChecks if the result is valid
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 596
- Return
boolean True if the result is valid else false
- Access
public
identifier
topReturns an object to represent a database identifier in a query
- Parameters:
-
-
string $identifier required
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 199
- Return
object An object representing a database identifier to be used in a query
- Access
public
index
topReturns an array of the indexes in given datasource name.
- Parameters:
-
-
string $model required
Name of model to inspect
-
- Method defined in:
- cake/libs/model/datasources/dbo/dbo_mysql.php on line 258
- Return
array Fields in table. Keys are column and unique
insertMulti
topInserts multiple values into a table
- Parameters:
-
-
string $table required
-
string $fields required
-
array $values required
-
- Method defined in:
- cake/libs/model/datasources/dbo/dbo_mysql.php on line 431
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.
introspectType
topGuesses the data type of an array
- Parameters:
-
-
string $value required
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 2877
- Return
void
- Access
public
isConnected
topChecks if the source is connected to the database.
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 586
- Return
boolean True if the database is connected, else false
- Access
public
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 number of affected rows in previous database operation. If no previous operation exists, this returns false.
- Method defined in:
- cake/libs/model/datasources/dbo/dbo_mysql.php on line 703
- Return
integer Number of affected rows
lastError
topReturns a formatted error message from previous database operation.
- Method defined in:
- cake/libs/model/datasources/dbo/dbo_mysql.php on line 690
- Return
string Error message with error number
lastInsertId
topReturns the ID generated from the previous INSERT operation.
- Parameters:
-
-
unknown_type $source optional NULL
-
- Method defined in:
- cake/libs/model/datasources/dbo/dbo_mysql.php on line 729
- Return
in
lastNumRows
topReturns number of rows in previous resultset. If no previous resultset exists, this returns false.
- Method defined in:
- cake/libs/model/datasources/dbo/dbo_mysql.php on line 716
- Return
integer Number of rows in resultset
length
topGets the length of a database-native column description, or null if no length
- Parameters:
-
-
string $real required
Real database-layer column type (i.e. "varchar(255)")
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 2519
- Return
mixed An integer or string representing the length of the column
- Access
public
limit
topReturns a limit statement in the correct format for the particular database.
- Parameters:
-
-
integer $limit required
Limit of results returned
-
integer $offset optional NULL
Offset from which to start results
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 2370
- Return
string SQL limit/offset statement
- Access
public
listDetailedSources
topReturns an detailed array of sources (tables) in the database.
- Parameters:
-
-
string $name optional NULL
Table name to get parameters
-
- Method defined in:
- cake/libs/model/datasources/dbo/dbo_mysql.php on line 445
- Return
array Array of tablenames in the database
listSources
topReturns an array of sources (tables) in the database.
- Method defined in:
- cake/libs/model/datasources/dbo/dbo_mysql.php on line 617
- Return
array Array of tablenames in the database
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
logQuery
topLog given SQL query.
- Parameters:
-
-
string $sql required
SQL statement
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 651
- Todo
: Add hook to log errors instead of returning false
- Access
public
_matchRecords
topGets a list of record IDs for the given conditions. Used for multi-record updates and deletes in databases that do not support aliases in UPDATE/DELETE queries.
- Parameters:
-
-
Model $model required
-
mixed $conditions optional NULL
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 1677
- Return
array List of record IDs
- Access
protected
__mergeHasMany
topmergeHasMany - Merge the results of hasMany relations.
- Parameters:
-
-
array $resultSet required
Data to merge into
-
array $merge required
Data to merge
-
string $association required
Name of Model being Merged
-
object $model required
Model being merged onto
-
object $linkModel required
Model being merged
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 1094
- Return
void
name
topReturns a quoted name of $data for use in an SQL statement. Strips fields out of SQL functions before quoting.
Results of this method are stored in a memory cache. This improves performance, but because the method uses a simple hashing algorithm it can infrequently have collisions. Setting DboSource::$cacheMethods to false will disable the memory cache.
- Parameters:
-
-
mixed $data required
Either a string with a column to quote. An array of columns to quote or an object from DboSource::expression() or DboSource::identifier()
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 527
- Return
string SQL field
- 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
order
topReturns an ORDER BY clause as a string.
- Parameters:
-
-
$keys required
-
string $direction optional 'ASC'
Direction (ASC or DESC)
-
object $model optional NULL
model reference (used to look for virtual field)
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 2396
- Return
string ORDER BY clause
- 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
topQuotes and prepares fields and values for an SQL UPDATE statement
- Parameters:
-
-
Model $model required
-
array $fields required
-
boolean $quoteValues optional true
If values should be quoted, or treated as SQL snippets
-
boolean $alias optional false
Include the model alias in the field name
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 1608
- Return
array Fields and values, quoted and preparted
- Access
protected
query
topDataSource Query abstraction
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 278
- Return
resource Result resource identifier.
- Access
public
queryAssociation
topQueries associations. Used to fetch results on recursive models.
- Parameters:
-
-
Model $model required
Primary Model object
-
Model $linkModel required
Linked model that
-
string $type required
Association type, one of the model association types ie. hasMany
-
unknown_type $association required
Association type, one of the model association types ie. hasMany
-
unknown_type $assocData required
Association type, one of the model association types ie. hasMany
-
array $queryData required
Association type, one of the model association types ie. hasMany
-
boolean $external required
Whether or not the association query is on an external datasource.
-
array $resultSet required
Existing results
-
integer $recursive required
Number of levels of association
-
array $stack required
Number of levels of association
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 919
rawQuery
topExecutes given SQL statement.
- Parameters:
-
-
string $sql required
SQL statement
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 227
- Return
boolean
- Access
public
read
topThe "R" in CRUD
Reads record(s) from the database.
- Parameters:
-
-
Model $model required
A Model object that the query is for.
-
array $queryData optional array ( )
An array of queryData information containing keys similar to Model::find()
-
integer $recursive optional NULL
Number of levels of association
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 775
- Return
mixed boolean false on error/failure. An array of results on success.
readTableParameters
topRead additional table parameters
- Parameters:
-
-
$name required
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 2836
- Return
array
- Access
public
reconnect
topReconnects to database server with optional new settings
- Parameters:
-
-
array $config optional array ( )
An array defining the new configuration settings
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 156
- Return
boolean True on success, false on failure
- Access
public
renderJoinStatement
topRenders a final SQL JOIN statement
- Parameters:
-
-
array $data required
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 1480
- Return
string
- Access
public
renderStatement
topRenders a final SQL statement by putting together the component parts in the correct order
- Parameters:
-
-
string $type required
type of query being run. e.g select, create, update, delete, schema, alter.
-
array $data required
Array of data to insert into the query.
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 1493
- Return
string Rendered SQL expression to be run.
- 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
topReturns a key formatted like a string Model.fieldname(i.e. Post.title, or Country.name)
- Parameters:
-
-
unknown_type $model required
-
unknown_type $key required
-
unknown_type $assoc optional NULL
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 1892
- Return
string
- Access
public
resultSet
topEnter description here...
- Parameters:
-
-
unknown_type $results required
-
- Method defined in:
- cake/libs/model/datasources/dbo/dbo_mysql.php on line 743
rollback
topRollback a transaction
(i.e. if the database/model does not support transactions, or a transaction has not started).
- Parameters:
-
-
model $model required
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 1842
- Return
boolean True on success, false on fail
- 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
__scrubQueryData
topPrivate helper method to remove query metadata in given data array.
- Parameters:
-
-
array $data required
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 1909
- Return
array
- Access
public
_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
setEncoding
topSets the database encoding
- Parameters:
-
-
string $enc required
Database encoding
-
- Method defined in:
- cake/libs/model/datasources/dbo/dbo_mysql.php on line 248
showLog
topOutputs the contents of the queries log. If in a non-CLI environment the sql_log element will be rendered and output. If in a CLI environment, a plain text log is generated.
- Parameters:
-
-
boolean $sorted optional false
Get the queries sorted by time taken, defaults to false.
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 626
- Return
void
showQuery
topOutput information about an SQL query. The SQL statement, number of rows in resultset, and execution time in microseconds. If the query fails, an error is output instead.
- Parameters:
-
-
string $sql required
Query to show information on.
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 676
- 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
truncate
topDeletes all the records in a table and resets the count of the auto-incrementing primary key, where applicable.
- Parameters:
-
-
mixed $table required
A string or model class representing the table to be truncated
-
- Method defined in:
- cake/libs/model/datasources/dbo_source.php on line 1795
- Return
boolean SQL TRUNCATE TABLE statement, false if not applicable.
- Access
public
update
topGenerates and executes an SQL UPDATE statement for given model, fields, and values.
- Parameters:
-
-
Model $model required
-
array $fields optional array ( )
-
array $values optional NULL
-
mixed $conditions optional NULL
-
- Method defined in:
- cake/libs/model/datasources/dbo/dbo_mysql.php on line 168
- Return
array
value
topReturns a quoted and escaped string of $data for use in an SQL statement.
- Parameters:
-
-
string $data required
String to be prepared for use in an SQL statement
-
string $column optional NULL
The column into which this data will be inserted
-
boolean $safe optional false
Whether or not numeric data should be handled automagically if no column data is provided
-
- Method defined in:
- cake/libs/model/datasources/dbo/dbo_mysql.php on line 645
- Return
string Quoted and escaped data