DboSource Class Reference

Inheritance diagram for DboSource:

DataSource Object DboAdodb DboDb2 DboFirebird DboMssql DboMysqlBase DboOdbc DboOracle DboPostgres DboSqlite DboSybase List of all members.

Public Member Functions

 __construct ($config=null, $autoConnect=true)
 __filterResults (&$results, &$model, $filtered=array())
 __mergeAssociation (&$data, $merge, $association, $type, $selfJoin=false)
 __mergeConditions ($query, $assoc)
 __mergeHasMany (&$resultSet, $merge, $association, &$model, &$linkModel)
 __parseKey ($model, $key, $value)
 __quoteFields ($conditions)
 __scrubQueryData ($data)
 _getJoins ($model)
 _matchRecords (&$model, $conditions=null)
 _prepareUpdateFields (&$model, $fields, $quoteValues=true, $alias=false)
 alterSchema ($compare, $table=null)
 begin (&$model)
 boolean ($data)
 buildColumn ($column)
 buildIndex ($indexes, $table=null)
 buildJoinStatement ($join)
 buildStatement ($query, $model)
 calculate (&$model, $func, $params=array())
 close ()
 commit (&$model)
 conditionKeysToString ($conditions, $quoteValues=true, $model=null)
 conditions ($conditions, $quoteValues=true, $where=true, $model=null)
 create (&$model, $fields=null, $values=null)
 createSchema ($schema, $tableName=null)
 defaultConditions (&$model, $conditions, $useAlias=true)
 delete (&$model, $conditions=null)
 dropSchema ($schema, $table=null)
 execute ($sql, $options=array())
 expression ($expression)
 fetchAll ($sql, $cache=true, $modelName=null)
 fetchAssociated ($model, $query, $ids)
 fetchRow ($sql=null)
 field ($name, $sql)
 fields (&$model, $alias=null, $fields=array(), $quote=true)
 fullTableName ($model, $quote=true)
 generateAssociationQuery (&$model, &$linkModel, $type, $association=null, $assocData=array(), &$queryData, $external=false, &$resultSet)
 getConstraint ($type, $model, $linkModel, $alias, $assoc, $alias2=null)
 group ($group)
 hasAny (&$Model, $sql)
 hasResult ()
 identifier ($identifier)
 index ($model)
 insertMulti ($table, $fields, $values)
 introspectType ($value)
 isConnected ()
 length ($real)
 limit ($limit, $offset=null)
 logQuery ($sql)
 name ($data)
 order ($keys, $direction= 'ASC')
 query ()
 queryAssociation (&$model, &$linkModel, $type, $association, $assocData, &$queryData, $external=false, &$resultSet, $recursive, $stack)
 rawQuery ($sql)
 read (&$model, $queryData=array(), $recursive=null)
 reconnect ($config=null)
 renderJoinStatement ($data)
 renderStatement ($type, $data)
 resolveKey ($model, $key, $assoc=null)
 rollback (&$model)
 showLog ($sorted=false)
 showQuery ($sql)
 truncate ($table)
 update (&$model, $fields=array(), $values=null, $conditions=null)
 value ($data, $column=null, $read=true)

Public Attributes

 $__bypass = false
 $__sqlOps = array('like', 'ilike', 'or', 'not', 'in', 'between', 'regexp', 'similar to')
 $_commands
 $alias = 'AS '
 $description = "Database Data Source"
 $fieldCache = array()
 $index = array('PRI' => 'primary', 'MUL' => 'index', 'UNI' => 'unique')

Detailed Description

Definition at line 37 of file dbo_source.php.


Constructor & Destructor Documentation

DboSource::__construct ( config = null,
autoConnect = true 
)

Constructor

Reimplemented in DboMssql.

Definition at line 88 of file dbo_source.php.

References DataSource::$config, __construct(), and Configure::read().


Member Function Documentation

DboSource::__filterResults ( &$  results,
&$  model,
filtered = array() 
)

Private method. Passes association results thru afterFind filters of corresponding model

Parameters:
array $results Reference of resultset to be filtered
object $model Instance of model to operate against
array $filtered List of classes already filtered, to be skipped
Returns:
return

Definition at line 699 of file dbo_source.php.

Referenced by queryAssociation(), and read().

DboSource::__mergeAssociation ( &$  data,
merge,
association,
type,
selfJoin = false 
)

Enter description here...

Parameters:
unknown_type $data
unknown_type $merge
unknown_type $association
unknown_type $type
boolean $selfJoin

Definition at line 950 of file dbo_source.php.

References Set::diff(), and pluralize().

Referenced by queryAssociation(), and DboOracle::queryAssociation().

DboSource::__mergeConditions ( query,
assoc 
)

Merges a mixed set of string/array conditions

Returns:
array

Definition at line 1341 of file dbo_source.php.

Referenced by generateAssociationQuery().

DboSource::__mergeHasMany ( &$  resultSet,
merge,
association,
&$  model,
&$  linkModel 
)

mergeHasMany - Merge the results of hasMany relations.

Parameters:
array $resultSet Data to merge into
array $merge Data to merge
string $association Name of Model being Merged
object $model Model being merged onto
object $linkModel Model being merged
Returns:
void

Definition at line 913 of file dbo_source.php.

References Set::pushDiff().

Referenced by queryAssociation(), and DboOracle::queryAssociation().

DboSource::__parseKey ( model,
key,
value 
)

Extracts a Model.field identifier and an SQL condition operator from a string, formats and inserts values, and composes them into an SQL snippet.

Parameters:
Model $model Model object initiating the query
string $key An SQL key snippet containing a field and optional SQL operator
mixed $value The value(s) to be inserted in the string
Returns:
string private

Definition at line 1893 of file dbo_source.php.

References __quoteFields(), conditionKeysToString(), String::insert(), name(), and value().

Referenced by conditionKeysToString().

DboSource::__quoteFields ( conditions  ) 

Quotes Model.fields

Parameters:
string $conditions
Returns:
string or false if no match private

Definition at line 1973 of file dbo_source.php.

Referenced by __parseKey(), conditionKeysToString(), and conditions().

DboSource::__scrubQueryData ( data  ) 

Private helper method to remove query metadata in given data array.

Parameters:
array $data
Returns:
array

Definition at line 1648 of file dbo_source.php.

References group().

Referenced by generateAssociationQuery(), and read().

DboSource::_getJoins ( model  ) 

Returns an array of SQL JOIN fragments from a model's associations

Parameters:
object $model
Returns:
array

Definition at line 1497 of file dbo_source.php.

References buildJoinStatement(), conditions(), fullTableName(), and getConstraint().

Referenced by DboMysqlBase::delete(), and DboMysqlBase::update().

DboSource::_matchRecords ( &$  model,
conditions = null 
)

Gets 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
mixed $conditions
Returns:
array List of record IDs protected

Definition at line 1471 of file dbo_source.php.

References conditions(), defaultConditions(), and Set::extract().

Referenced by delete(), and update().

DboSource::_prepareUpdateFields ( &$  model,
fields,
quoteValues = true,
alias = false 
)

Quotes and prepares fields and values for an SQL UPDATE statement

Parameters:
Model $model
array $fields
boolean $quoteValues If values should be quoted, or treated as SQL snippets
boolean $alias Include the model alias in the field name
Returns:
array Fields and values, quoted and preparted protected

Definition at line 1405 of file dbo_source.php.

References $alias, name(), and value().

Referenced by update(), and DboMysqlBase::update().

DboSource::alterSchema ( compare,
table = null 
)

Generate a alter syntax from CakeSchema::compare()

Parameters:
unknown_type $schema
Returns:
unknown

Reimplemented in DboMysqlBase, DboOracle, and DboPostgres.

Definition at line 2292 of file dbo_source.php.

DboSource::begin ( &$  model  ) 

Begin a transaction

Parameters:
model $model
Returns:
boolean True on success, false on fail (i.e. if the database/model does not support transactions, or a transaction has not started).

Reimplemented from DataSource.

Reimplemented in DboAdodb, DboDb2, and DboSybase.

Definition at line 1566 of file dbo_source.php.

References execute().

DboSource::boolean ( data  ) 

Translates between PHP boolean values and Database (faked) boolean values

Parameters:
mixed $data Value to be translated
Returns:
mixed Converted boolean value

Reimplemented in DboDb2.

Definition at line 2201 of file dbo_source.php.

Referenced by DboSybase::value(), DboSqlite::value(), DboMysqli::value(), DboMysql::value(), DboMssql::value(), and DboFirebird::value().

DboSource::buildColumn ( column  ) 

Generate a database-native column schema string

Parameters:
array $column An array structured like the following: array('name'=>'value', 'type'=>'value'[, options]), where options can be 'default', 'length', or 'key'.
Returns:
string

Reimplemented in DboAdodb, DboMssql, DboPostgres, and DboSqlite.

Definition at line 2324 of file dbo_source.php.

Referenced by DboOracle::alterSchema(), and DboMysqlBase::alterSchema().

DboSource::buildIndex ( indexes,
table = null 
)

Format indexes for create table

Parameters:
array $indexes
string $table
Returns:
array

Reimplemented in DboMssql, DboPostgres, and DboSqlite.

Definition at line 2380 of file dbo_source.php.

DboSource::buildJoinStatement ( join  ) 

Builds and generates a JOIN statement from an array. Handles final clean-up before conversion.

Parameters:
array $join An array defining a JOIN statement in a query
Returns:
string An SQL JOIN statement to be used in a query
See also:
DboSource::renderJoinStatement()

DboSource::buildStatement()

Definition at line 1236 of file dbo_source.php.

References conditions(), name(), and renderJoinStatement().

Referenced by _getJoins(), and buildStatement().

DboSource::buildStatement ( query,
model 
)

Builds and generates an SQL statement from an array. Handles final clean-up before conversion.

Parameters:
array $query An array defining an SQL query
object $model The model object which initiated the query
Returns:
string An executable SQL statement
See also:
DboSource::renderStatement()

Definition at line 1260 of file dbo_source.php.

References buildJoinStatement(), conditions(), group(), limit(), name(), order(), and renderStatement().

Referenced by generateAssociationQuery().

DboSource::calculate ( &$  model,
func,
params = array() 
)

Returns an SQL calculation, i.e. COUNT() or MAX()

Parameters:
model $model
string $func Lowercase name of SQL function, i.e. 'count' or 'max'
array $params Function parameters (any values must be quoted manually)
Returns:
string An SQL calculation function public

Definition at line 1526 of file dbo_source.php.

References name().

DboSource::close (  ) 

Disconnects database, kills the connection and says the connection is closed, and if DEBUG is turned on, the log for this object is shown.

Definition at line 2109 of file dbo_source.php.

DboSource::commit ( &$  model  ) 

Commit a transaction

Parameters:
model $model
Returns:
boolean True on success, false on fail (i.e. if the database/model does not support transactions, or a transaction has not started).

Reimplemented from DataSource.

Reimplemented in DboAdodb, DboDb2, and DboSybase.

Definition at line 1581 of file dbo_source.php.

References execute().

DboSource::conditionKeysToString ( conditions,
quoteValues = true,
model = null 
)

Creates a WHERE clause by parsing given conditions array. Used by DboSource::conditions().

Parameters:
array $conditions Array or string of conditions
boolean $quoteValues If true, values should be quoted
Model $model A reference to the Model instance making the query
Returns:
string SQL fragment

Definition at line 1784 of file dbo_source.php.

References $out, __parseKey(), __quoteFields(), expression(), identifier(), name(), and value().

Referenced by __parseKey(), and conditions().

DboSource::conditions ( conditions,
quoteValues = true,
where = true,
model = null 
)

Creates a WHERE clause by parsing given conditions data.

Parameters:
mixed $conditions Array or string of conditions
boolean $quoteValues If true, values should be quoted
boolean $where If true, "WHERE " will be prepended to the return value
Model $model A reference to the Model instance making the query
Returns:
string SQL fragment

Definition at line 1745 of file dbo_source.php.

References $out, __quoteFields(), and conditionKeysToString().

Referenced by _getJoins(), _matchRecords(), buildJoinStatement(), buildStatement(), DboMysqlBase::delete(), generateAssociationQuery(), query(), and DboMysqlBase::update().

DboSource::create ( &$  model,
fields = null,
values = null 
)

The "C" in CRUD

Parameters:
Model $model
array $fields
array $values
Returns:
boolean Success

Reimplemented from DataSource.

Reimplemented in DboMssql.

Definition at line 559 of file dbo_source.php.

References $id, execute(), fields(), fullTableName(), DataSource::lastInsertId(), name(), renderStatement(), and value().

Referenced by renderStatement(), and DboOracle::renderStatement().

DboSource::createSchema ( schema,
tableName = null 
)

Generate a database-native schema for the given Schema object

Parameters:
object $schema An instance of a subclass of CakeSchema
string $tableName Optional. If specified only the table name given will be generated. Otherwise, all tables defined in the schema are generated.
Returns:
string

Definition at line 2246 of file dbo_source.php.

DboSource::defaultConditions ( &$  model,
conditions,
useAlias = true 
)

Creates a default set of conditions from the model if $conditions is null/empty.

Parameters:
object $model
mixed $conditions
boolean $useAlias Use model aliases rather than table names when generating conditions
Returns:
mixed

Definition at line 1611 of file dbo_source.php.

References $alias, exists(), and fullTableName().

Referenced by _matchRecords(), DboMysqlBase::delete(), and DboMysqlBase::update().

DboSource::delete ( &$  model,
conditions = null 
)

Generates and executes an SQL DELETE statement. For databases that do not support aliases in UPDATE queries.

Parameters:
Model $model
mixed $conditions
Returns:
boolean Success

Reimplemented from DataSource.

Reimplemented in DboMysqlBase.

Definition at line 1447 of file dbo_source.php.

References $alias, _matchRecords(), execute(), fullTableName(), and renderStatement().

DboSource::dropSchema ( schema,
table = null 
)

Generate a "drop table" statement for the given Schema object

Parameters:
object $schema An instance of a subclass of CakeSchema
string $table Optional. If specified only the table name given will be generated. Otherwise, all tables defined in the schema are generated.
Returns:
string

Reimplemented in DboMysqlBase, and DboOracle.

Definition at line 2303 of file dbo_source.php.

DboSource::execute ( sql,
options = array() 
)

Queries 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 DEBUG is set, the log is shown all the time, else it is only shown on errors.

Parameters:
string $sql
array $options
Returns:
mixed Resource or object representing the result set, or false on failure

Definition at line 183 of file dbo_source.php.

References error(), DataSource::lastAffected(), DataSource::lastNumRows(), Object::log(), logQuery(), and showQuery().

Referenced by begin(), DboSybase::begin(), commit(), DboSybase::commit(), DboOracle::connect(), DboOracle::constraint(), create(), DboOracle::createSequence(), DboOracle::createTrigger(), delete(), DboMysqlBase::delete(), DboOracle::describe(), fetchAll(), fetchRow(), DboAdodb::fetchRow(), DboOracle::getEncoding(), DboOracle::lastInsertId(), DboOracle::listSources(), rawQuery(), rollback(), DboSybase::rollback(), DboOracle::sequenceExists(), DboOracle::setEncoding(), truncate(), DboOracle::truncate(), update(), and DboMysqlBase::update().

DboSource::expression ( expression  ) 

Returns an object to represent a database expression in a query

Parameters:
string $expression
Returns:
object An object representing a database expression to be used in a query

Definition at line 158 of file dbo_source.php.

Referenced by conditionKeysToString(), and value().

DboSource::fetchAll ( sql,
cache = true,
modelName = null 
)

Returns an array of all result rows for a given SQL query. Returns false if no rows matched.

Parameters:
string $sql SQL statement
boolean $cache Enables returning/storing cached query results
Returns:
array Array of resultset rows, or false if no rows matched

Definition at line 329 of file dbo_source.php.

References $out, execute(), fetchRow(), and hasResult().

Referenced by DboSqlite::describe(), DboPostgres::describe(), DboMssql::describe(), fetchAssociated(), DboSqlite::listSources(), DboPostgres::listSources(), DboMssql::listSources(), query(), queryAssociation(), DboOracle::queryAssociation(), and read().

DboSource::fetchAssociated ( model,
query,
ids 
)

A more efficient way to fetch associations. Woohoo!

Parameters:
model $model Primary model object
string $query Association query
array $ids Array of IDs of associated records
Returns:
array Association results

Definition at line 894 of file dbo_source.php.

References fetchAll().

Referenced by queryAssociation().

DboSource::fetchRow ( sql = null  ) 

Returns a row from current resultset as an array

Returns:
array The fetched row as an array

Reimplemented in DboAdodb.

Definition at line 306 of file dbo_source.php.

References execute(), and hasResult().

Referenced by fetchAll(), field(), DboSqlite::getEncoding(), DboSybase::lastInsertId(), DboOdbc::lastInsertId(), DboMysqli::lastInsertId(), DboMysql::lastInsertId(), and DboDb2::lastInsertId().

DboSource::field ( name,
sql 
)

Returns a single field of the first of query results for a given SQL query, or false if empty.

Parameters:
string $name Name of the field
string $sql SQL query
Returns:
unknown

Definition at line 365 of file dbo_source.php.

References fetchRow().

DboSource::fields ( &$  model,
alias = null,
fields = array(),
quote = true 
)

Generates the fields list of an SQL query.

Parameters:
Model $model
string $alias Alias tablename
mixed $fields
boolean $quote If false, returns fields array unquoted
Returns:
array

Reimplemented in DboAdodb, DboMssql, DboOdbc, and DboPostgres.

Definition at line 1665 of file dbo_source.php.

References $alias, false, name(), Set::numeric(), and String::tokenize().

Referenced by create(), generateAssociationQuery(), query(), read(), and DboMysqlBase::update().

DboSource::fullTableName ( model,
quote = true 
)

Gets full table name including prefix

Parameters:
mixed $model
boolean $quote
Returns:
string Full quoted table name

Definition at line 538 of file dbo_source.php.

References config(), and name().

Referenced by _getJoins(), DboPostgres::alterSchema(), DboOracle::alterSchema(), DboMysqlBase::alterSchema(), create(), defaultConditions(), delete(), DboMysqlBase::delete(), DboSybase::describe(), DboSqlite::describe(), DboPostgres::describe(), DboOracle::describe(), DboOdbc::describe(), DboMysqli::describe(), DboMysql::describe(), DboMssql::describe(), DboFirebird::describe(), DboDb2::describe(), DboAdodb::describe(), DboOracle::dropSchema(), DboMysqlBase::dropSchema(), generateAssociationQuery(), DboSqlite::index(), DboPostgres::index(), DboOracle::index(), DboMysqlBase::index(), DboMysqlBase::insertMulti(), truncate(), DboSqlite::truncate(), DboOracle::truncate(), update(), and DboMysqlBase::update().

DboSource::generateAssociationQuery ( &$  model,
&$  linkModel,
type,
association = null,
assocData = array(),
&$  queryData,
external = false,
&$  resultSet 
)

Generates an array representing a query or part of a query from a single model or two associated models

Parameters:
Model $model
Model $linkModel
string $type
string $association
array $assocData
array $queryData
boolean $external
array $resultSet
Returns:
mixed

Definition at line 1032 of file dbo_source.php.

References $alias, __mergeConditions(), __scrubQueryData(), buildStatement(), conditions(), fields(), fullTableName(), getConstraint(), group(), limit(), offset(), and order().

Referenced by queryAssociation(), DboOracle::queryAssociation(), and read().

DboSource::getConstraint ( type,
model,
linkModel,
alias,
assoc,
alias2 = null 
)

Returns a conditions array for the constraint between two models

Parameters:
string $type Association type
object $model Model object
array $association Association array
Returns:
array Conditions array defining the constraint between $model and $association

Definition at line 1196 of file dbo_source.php.

References identifier().

Referenced by _getJoins(), and generateAssociationQuery().

DboSource::group ( group  ) 

Create a GROUP BY SQL clause

Parameters:
string $group Group By Condition
Returns:
mixed string condition or null

Definition at line 2095 of file dbo_source.php.

Referenced by __scrubQueryData(), buildStatement(), and generateAssociationQuery().

DboSource::hasAny ( &$  Model,
sql 
)

Checks if the specified table contains any record matching specified SQL

Parameters:
Model $model Model to search
string $sql SQL WHERE clause (condition only, not the "WHERE" part)
Returns:
boolean True if the table has a matching record, else false

Definition at line 2122 of file dbo_source.php.

References $alias, and $id.

DboSource::hasResult (  ) 

Checks if the result is valid

Returns:
boolean True if the result is valid else false

Reimplemented in DboAdodb, and DboMysqli.

Definition at line 452 of file dbo_source.php.

Referenced by DboPostgres::disconnect(), fetchAll(), fetchRow(), DboFirebird::fetchRow(), DboOdbc::lastAffected(), DboSybase::lastNumRows(), DboSqlite::lastNumRows(), DboOdbc::lastNumRows(), and DboMysql::lastNumRows().

DboSource::identifier ( identifier  ) 

Returns an object to represent a database identifier in a query

Parameters:
string $identifier
Returns:
object An object representing a database identifier to be used in a query

Definition at line 146 of file dbo_source.php.

Referenced by conditionKeysToString(), getConstraint(), and value().

DboSource::index ( model  ) 

Returns an array of the indexes in given datasource name.

Parameters:
string $model Name of model to inspect
Returns:
array Fields in table. Keys are column and unique

Reimplemented in DboMysqlBase, DboOracle, and DboPostgres.

Definition at line 2235 of file dbo_source.php.

DboSource::insertMulti ( table,
fields,
values 
)

Inserts multiple values into a table

Parameters:
string $table
string $fields
array $values protected

Reimplemented in DboMssql, and DboMysqlBase.

Definition at line 2219 of file dbo_source.php.

DboSource::introspectType ( value  ) 

Guesses the data type of an array

Parameters:
string $value
Returns:
void public

Definition at line 2409 of file dbo_source.php.

Referenced by DboMysqli::value(), and DboMysql::value().

DboSource::isConnected (  ) 

Checks if it's connected to the database

Returns:
boolean True if the database is connected, else false

Definition at line 444 of file dbo_source.php.

DboSource::length ( real  ) 

Gets the length of a database-native column description, or null if no length

Parameters:
string $real Real database-layer column type (i.e. "varchar(255)")
Returns:
mixed An integer or string representing the length of the column

Reimplemented in DboMysqli, and DboPostgres.

Definition at line 2142 of file dbo_source.php.

Referenced by DboSqlite::buildColumn(), DboAdodb::buildColumn(), DboMysql::column(), DboSybase::describe(), DboSqlite::describe(), DboOracle::describe(), DboMysql::describe(), DboMssql::describe(), DboFirebird::describe(), DboDb2::describe(), and DboAdodb::describe().

DboSource::limit ( limit,
offset = null 
)

Returns a limit statement in the correct format for the particular database.

Parameters:
integer $limit Limit of results returned
integer $offset Offset from which to start results
Returns:
string SQL limit/offset statement

Reimplemented in DboAdodb, DboDb2, DboFirebird, DboMssql, DboOracle, DboPostgres, and DboSqlite.

Definition at line 2005 of file dbo_source.php.

Referenced by buildStatement(), DboSybase::column(), DboOdbc::column(), DboMysqli::column(), DboMysql::column(), generateAssociationQuery(), query(), and queryAssociation().

DboSource::logQuery ( sql  ) 

Log given SQL query.

Parameters:
string $sql SQL statement
Todo:
: Add hook to log errors instead of returning false

Definition at line 493 of file dbo_source.php.

References error(), and query().

Referenced by execute().

DboSource::name ( data  ) 

Returns a quoted name of $data for use in an SQL statement. Strips fields out of SQL functions before quoting.

Parameters:
string $data
Returns:
string SQL field

Reimplemented in DboDb2, DboFirebird, DboOracle, and DboPostgres.

Definition at line 381 of file dbo_source.php.

References Set::extract().

Referenced by __parseKey(), DboMysqlBase::_alterIndexes(), _prepareUpdateFields(), DboMysqlBase::alterSchema(), DboSqlite::buildColumn(), DboAdodb::buildColumn(), DboSqlite::buildIndex(), buildJoinStatement(), buildStatement(), calculate(), DboSybase::column(), DboSqlite::column(), DboOdbc::column(), DboMysqli::column(), DboMysql::column(), conditionKeysToString(), create(), DboMysqlBase::delete(), DboSqlite::describe(), fields(), DboOdbc::fields(), DboMssql::fields(), DboAdodb::fields(), fullTableName(), DboSqlite::index(), DboMysqlBase::insertMulti(), DboSqlite::listSources(), DboMysqli::listSources(), DboMysql::listSources(), queryAssociation(), resolveKey(), DboSybase::resultSet(), DboMysqli::resultSet(), DboMysql::resultSet(), DboMysqlBase::update(), and value().

DboSource::order ( keys,
direction = 'ASC' 
)

Returns an ORDER BY clause as a string.

Parameters:
string $key Field reference, as a key (i.e. Post.title)
string $direction Direction (ASC or DESC)
Returns:
string ORDER BY clause

Definition at line 2028 of file dbo_source.php.

Referenced by buildStatement(), generateAssociationQuery(), and query().

DboSource::query (  ) 

DataSource Query abstraction

Returns:
resource Result resource identifier

Definition at line 211 of file dbo_source.php.

References conditions(), fetchAll(), fields(), String::insert(), limit(), order(), underscore(), and value().

Referenced by DboSybase::describe(), DboMysqli::describe(), DboMysql::describe(), DboSqlite::index(), DboPostgres::index(), DboOracle::index(), DboMysqlBase::index(), DboMysqlBase::insertMulti(), logQuery(), and showLog().

DboSource::queryAssociation ( &$  model,
&$  linkModel,
type,
association,
assocData,
&$  queryData,
external = false,
&$  resultSet,
recursive,
stack 
)

Enter description here...

Parameters:
Model $model
unknown_type $linkModel
string $type Association type
unknown_type $association
unknown_type $assocData
unknown_type $queryData
unknown_type $external
unknown_type $resultSet
integer $recursive Number of levels of association
array $stack

Reimplemented in DboOracle.

Definition at line 741 of file dbo_source.php.

References __(), __filterResults(), __mergeAssociation(), __mergeHasMany(), error(), fetchAll(), fetchAssociated(), generateAssociationQuery(), ConnectionManager::getDataSource(), DataSource::insertQueryData(), limit(), name(), and Configure::read().

DboSource::rawQuery ( sql  ) 

Executes given SQL statement.

Parameters:
string $sql SQL statement
Returns:
unknown

Definition at line 170 of file dbo_source.php.

References error(), and execute().

Referenced by DboFirebird::lastInsertId().

DboSource::read ( &$  model,
queryData = array(),
recursive = null 
)

The "R" in CRUD

Parameters:
Model $model
array $queryData
integer $recursive Number of levels of association
Returns:
unknown

Reimplemented in DboMssql.

Definition at line 604 of file dbo_source.php.

References __filterResults(), __scrubQueryData(), fetchAll(), fields(), generateAssociationQuery(), and ConnectionManager::getDataSource().

DboSource::reconnect ( config = null  ) 

Reconnects to database server with optional new settings

Parameters:
array $config An array defining the new configuration settings
Returns:
boolean True on success, false on failure

Definition at line 107 of file dbo_source.php.

References DataSource::$config, and DataSource::setConfig().

DboSource::renderJoinStatement ( data  ) 

Renders a final SQL JOIN statement

Parameters:
array $data
Returns:
string

Definition at line 1287 of file dbo_source.php.

Referenced by buildJoinStatement().

DboSource::renderStatement ( type,
data 
)

Renders a final SQL statement by putting together the component parts in the correct order

Parameters:
string $type
array $data
Returns:
string

Reimplemented in DboFirebird, DboMssql, DboOracle, DboPostgres, and DboSqlite.

Definition at line 1298 of file dbo_source.php.

References $alias, create(), and update().

Referenced by buildStatement(), create(), delete(), DboMysqlBase::delete(), update(), and DboMysqlBase::update().

DboSource::resolveKey ( model,
key,
assoc = null 
)

Returns a key formatted like a string Model.fieldname(i.e. Post.title, or Country.name)

Parameters:
unknown_type $model
unknown_type $key
unknown_type $assoc
Returns:
string

Definition at line 1633 of file dbo_source.php.

References name().

DboSource::rollback ( &$  model  ) 

Rollback a transaction

Parameters:
model $model
Returns:
boolean True on success, false on fail (i.e. if the database/model does not support transactions, or a transaction has not started).

Reimplemented from DataSource.

Reimplemented in DboAdodb, DboDb2, and DboSybase.

Definition at line 1596 of file dbo_source.php.

References execute().

DboSource::showLog ( sorted = false  ) 

Outputs the contents of the queries log.

Parameters:
boolean $sorted

Definition at line 460 of file dbo_source.php.

References query().

DboSource::showQuery ( sql  ) 

Output 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 Query to show information on.

Definition at line 516 of file dbo_source.php.

References DataSource::$error, $out, error(), pr(), and Configure::read().

Referenced by execute().

DboSource::truncate ( table  ) 

Deletes all the records in a table and resets the count of the auto-incrementing primary key, where applicable.

Parameters:
mixed $table A string or model class representing the table to be truncated
Returns:
boolean SQL TRUNCATE TABLE statement, false if not applicable. public

Reimplemented in DboSqlite.

Definition at line 1555 of file dbo_source.php.

References execute(), and fullTableName().

DboSource::update ( &$  model,
fields = array(),
values = null,
conditions = null 
)

Generates and executes an SQL UPDATE statement for given model, fields, and values. For databases that do not support aliases in UPDATE queries.

Parameters:
Model $model
array $fields
array $values
mixed $conditions
Returns:
boolean Success

Reimplemented in DboMssql, DboMysqlBase, and DboSqlite.

Definition at line 1372 of file dbo_source.php.

References $alias, _matchRecords(), _prepareUpdateFields(), execute(), fullTableName(), and renderStatement().

Referenced by renderStatement(), and DboOracle::renderStatement().

DboSource::value ( data,
column = null,
read = true 
)

Prepares a value, or an array of values for database queries by quoting and escaping them.

Parameters:
mixed $data A value or an array of values to prepare.
string $column The column into which this data will be inserted
boolean $read Value to be used in READ or WRITE context
Returns:
mixed Prepared value or array of values.

Reimplemented in DboAdodb, DboDb2, DboFirebird, DboMssql, DboMysql, DboMysqli, DboOracle, DboPostgres, DboSqlite, and DboSybase.

Definition at line 122 of file dbo_source.php.

References expression(), identifier(), and name().

Referenced by __parseKey(), _prepareUpdateFields(), conditionKeysToString(), create(), and query().


Member Data Documentation

DboSource::$__bypass = false

Definition at line 67 of file dbo_source.php.

DboSource::$__sqlOps = array('like', 'ilike', 'or', 'not', 'in', 'between', 'regexp', 'similar to')

Definition at line 73 of file dbo_source.php.

DboSource::$_commands

Initial value:

 array(
        'begin'    => 'BEGIN',
        'commit'   => 'COMMIT',
        'rollback' => 'ROLLBACK'
    )

Reimplemented in DboFirebird, DboMssql, DboMysqlBase, DboPostgres, and DboSqlite.

Definition at line 80 of file dbo_source.php.

DboSource::$alias = 'AS '

Reimplemented in DboFirebird, and DboOracle.

Definition at line 55 of file dbo_source.php.

Referenced by _prepareUpdateFields(), defaultConditions(), delete(), DboMysqlBase::delete(), fields(), DboPostgres::fields(), DboOdbc::fields(), DboMssql::fields(), DboAdodb::fields(), generateAssociationQuery(), hasAny(), renderStatement(), update(), and DboMysqlBase::update().

DboSource::$description = "Database Data Source"

Reimplemented in DboAdodb, DboDb2, DboFirebird, DboMssql, DboMysqlBase, DboMysql, DboMysqli, DboOdbc, DboPostgres, DboSqlite, and DboSybase.

Definition at line 43 of file dbo_source.php.

DboSource::$fieldCache = array()

Definition at line 61 of file dbo_source.php.

DboSource::$index = array('PRI' => 'primary', 'MUL' => 'index', 'UNI' => 'unique')

Definition at line 49 of file dbo_source.php.

Referenced by DboDb2::_execute(), DboSybase::fetchResult(), DboSqlite::fetchResult(), DboPostgres::fetchResult(), DboMysqli::fetchResult(), DboMysql::fetchResult(), DboFirebird::fetchResult(), DboDb2::fetchResult(), DboOracle::fetchRow(), DboSqlite::index(), DboPostgres::index(), DboOracle::index(), DboMysqlBase::index(), DboPostgres::renderStatement(), DboSybase::resultSet(), DboSqlite::resultSet(), DboPostgres::resultSet(), DboOdbc::resultSet(), DboMysqli::resultSet(), DboMysql::resultSet(), DboFirebird::resultSet(), and DboAdodb::resultSet().


The documentation for this class was generated from the following file:
Generated on Sun Nov 22 00:30:55 2009 for CakePHP 1.2.x.x (v1.2.4.8284) by doxygen 1.4.7