CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (GitHub)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • Slack
    • Paid Support
CakePHP

C CakePHP 1.3 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 1.3
      • 4.2
      • 4.1
      • 4.0
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Classes

  • AclBase
  • AclBehavior
  • AclComponent
  • AclNode
  • AclShell
  • Aco
  • AcoAction
  • AjaxHelper
  • ApcEngine
  • ApiShell
  • App
  • AppController
  • AppHelper
  • AppModel
  • Aro
  • AuthComponent
  • BakeShell
  • BakeTask
  • BehaviorCollection
  • Cache
  • CacheEngine
  • CacheHelper
  • CakeErrorController
  • CakeLog
  • CakeRoute
  • CakeSchema
  • CakeSession
  • CakeSocket
  • ClassRegistry
  • Component
  • Configure
  • ConnectionManager
  • ConsoleShell
  • ContainableBehavior
  • Controller
  • ControllerTask
  • CookieComponent
  • DataSource
  • DbAcl
  • DbConfigTask
  • DboMssql
  • DboMysql
  • DboMysqlBase
  • DboMysqli
  • DboOracle
  • DboPostgres
  • DboSource
  • DboSqlite
  • Debugger
  • EmailComponent
  • ErrorHandler
  • ExtractTask
  • File
  • FileEngine
  • FileLog
  • FixtureTask
  • Folder
  • FormHelper
  • Helper
  • HtmlHelper
  • HttpSocket
  • I18n
  • I18nModel
  • I18nShell
  • Inflector
  • IniAcl
  • JavascriptHelper
  • JqueryEngineHelper
  • JsBaseEngineHelper
  • JsHelper
  • L10n
  • MagicDb
  • MagicFileResource
  • MediaView
  • MemcacheEngine
  • Model
  • ModelBehavior
  • ModelTask
  • MootoolsEngineHelper
  • Multibyte
  • NumberHelper
  • Object
  • Overloadable
  • Overloadable2
  • PagesController
  • PaginatorHelper
  • Permission
  • PluginShortRoute
  • PluginTask
  • ProjectTask
  • PrototypeEngineHelper
  • RequestHandlerComponent
  • Router
  • RssHelper
  • Sanitize
  • Scaffold
  • ScaffoldView
  • SchemaShell
  • Security
  • SecurityComponent
  • SessionComponent
  • SessionHelper
  • Set
  • Shell
  • String
  • TemplateTask
  • TestSuiteShell
  • TestTask
  • TextHelper
  • ThemeView
  • TimeHelper
  • TranslateBehavior
  • TreeBehavior
  • Validation
  • View
  • ViewTask
  • XcacheEngine
  • Xml
  • XmlElement
  • XmlHelper
  • XmlManager
  • XmlNode
  • XmlTextNode

Functions

  • mb_encode_mimeheader
  • mb_stripos
  • mb_stristr
  • mb_strlen
  • mb_strpos
  • mb_strrchr
  • mb_strrichr
  • mb_strripos
  • mb_strrpos
  • mb_strstr
  • mb_strtolower
  • mb_strtoupper
  • mb_substr
  • mb_substr_count

Class DboPostgres

PostgreSQL layer for DBO.

Long description for class

Object
Extended by DataSource
Extended by DboSource
Extended by DboPostgres
Package: cake\cake\libs\model\datasources\dbo
Copyright: Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
License: License (http://www.opensource.org/licenses/mit-license.php)
Location: model/datasources/dbo/dbo_postgres.php

Properties summary

  • $_baseConfig public
    array
    Base driver configuration settings. Merged with user settings.
  • $_commands public
    array
    Index of basic SQL commands
  • $_sequenceMap public
    array

    Contains mappings of custom auto-increment sequences, if a table uses a sequence name other than what is dictated by convention.

  • $columns public
    array
  • $description public
    string
    Driver description
  • $endQuote public
    string
    Ending Quote
  • $startQuote public
    string
    Starting Quote

Inherited Properties

  • __bypass, __sqlOps, alias, cacheMethods, fieldParameters, index, methodCache, tableParameters, virtualFieldSeparator __descriptions, _queriesCnt, _queriesLog, _queriesLogMax, _queriesTime, _queryCache, _result, _sources, _transactionStarted, affected, cacheSources, config, configKeyName, connected, connection, error, fullDebug, numRows, took

Method Summary

  • __quoteFunctionField() public

    Auxiliary function to quote matched (Model.fields) from a preg_replace_callback call Quotes the fields in a function call.

  • _alterIndexes() public
    Generate PostgreSQL index alteration statements for a table.
  • _execute() public
    Executes given SQL statement.
  • alterSchema() public
    Alter the Schema of a table.
  • boolean() public
    Translates between PHP boolean values and PostgreSQL boolean values
  • buildColumn() public
    Generate a Postgres-native column schema string
  • buildIndex() public
    Format indexes for create table
  • column() public
    Converts database-layer column types to basic types
  • connect() public
    Connects to the database using options in the given configuration array.
  • describe() public
    Returns an array of the fields in given table name.
  • disconnect() public
    Disconnects from database.
  • enabled() public
    Check if PostgreSQL is enabled/loaded
  • fetchResult() public
    Fetches the next row from the current result set
  • fields() public
    Generates the fields list of an SQL query.
  • getEncoding() public
    Gets the database encoding
  • getSequence() public
    Gets the associated sequence for the given table/field
  • index() public
    Returns an array of the indexes in given datasource name.
  • lastAffected() public
    Returns number of affected rows in previous database operation. If no previous operation exists, this returns false.
  • lastError() public
    Returns a formatted error message from previous database operation.
  • lastInsertId() public
    Returns the ID generated from the previous INSERT operation.
  • lastNumRows() public

    Returns number of rows in previous resultset. If no previous resultset exists, this returns false.

  • length() public
    Gets the length of a database-native column description, or null if no length
  • limit() public
    Returns a limit statement in the correct format for the particular database.
  • listSources() public
    Returns an array of tables in the database. If there are no tables, an error is raised and the application exits.
  • name() public
    Prepares field names to be quoted by parent
  • renderStatement() public
    Overrides DboSource::renderStatement to handle schema generation with Postgres-style indexes
  • resultSet() public
    Enter description here...
  • setEncoding() public
    Sets the database encoding
  • truncate() public
    Deletes all the records in a table and drops all associated auto-increment sequences
  • value() public
    Returns a quoted and escaped string of $data for use in an SQL statement.

Method Detail

__quoteFunctionField() public ¶

__quoteFunctionField( string $match )

Auxiliary function to quote matched (Model.fields) from a preg_replace_callback call Quotes the fields in a function call.

Parameters
string $match
string
Returns
string
quoted strig

_alterIndexes() public ¶

_alterIndexes( string $table , array $indexes )

Generate PostgreSQL index alteration statements for a table.

Parameters
string $table
Table to alter indexes for
array $indexes
$new Indexes to add and drop
Returns
array
Index alteration statements

_execute() public ¶

_execute( string $sql )

Executes given SQL statement.

Parameters
string $sql
SQL statement
Returns
resource
Result resource identifier

alterSchema() public ¶

alterSchema( array $compare , string $table = null )

Alter the Schema of a table.

Parameters
array $compare
Results of CakeSchema::compare()
string $table optional null
name of the table
Returns
array
Overrides
DboSource::alterSchema()

boolean() public ¶

boolean( mixed $data , boolean $quote = true )

Translates between PHP boolean values and PostgreSQL boolean values

Parameters
mixed $data
Value to be translated
boolean $quote optional true
True to quote value, false otherwise
Returns
mixed
Converted boolean value
Overrides
DboSource::boolean()

buildColumn() public ¶

buildColumn( array $column )

Generate a Postgres-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
Overrides
DboSource::buildColumn()

buildIndex() public ¶

buildIndex( array $indexes , string $table = null )

Format indexes for create table

Parameters
array $indexes
string $table optional null
Returns
string
Overrides
DboSource::buildIndex()

column() public ¶

column( string $real )

Converts database-layer column types to basic types

Parameters
string $real
Real database-layer column type (i.e. "varchar(255)")
Returns
string
Abstract column type (i.e. "string")
Overrides
DataSource::column()

connect() public ¶

connect( )

Connects to the database using options in the given configuration array.

Returns
True
if successfully connected.

describe() public ¶

describe( string $model )

Returns an array of the fields in given table name.

Parameters
string $model
$tableName Name of database table to inspect
Returns
array
Fields in table. Keys are name and type
Overrides
DataSource::describe()

disconnect() public ¶

disconnect( )

Disconnects from database.

Returns
boolean
True if the database could be disconnected, else false

enabled() public ¶

enabled( )

Check if PostgreSQL is enabled/loaded

Returns
boolean
Overrides
DataSource::enabled()

fetchResult() public ¶

fetchResult( )

Fetches the next row from the current result set

Returns
unknown

fields() public ¶

fields( Model $model , string $alias = null , mixed $fields = array() , boolean $quote = true )

Generates the fields list of an SQL query.

Parameters
Model $model
string $alias optional null
Alias tablename
mixed $fields optional array()
boolean $quote optional true
If false, returns fields array unquoted
Returns
array
Overrides
DboSource::fields()

getEncoding() public ¶

getEncoding( )

Gets the database encoding

Returns
string
The database encoding

getSequence() public ¶

getSequence( mixed $table , string $field = 'id' )

Gets the associated sequence for the given table/field

Parameters
mixed $table
Either a full table name (with prefix) as a string, or a model object
string $field optional 'id'
Name of the ID database field. Defaults to "id"
Returns
string
The associated sequence name from the sequence map, defaults to "{$table}_{$field}_seq"

index() public ¶

index( string $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
Overrides
DboSource::index()

lastAffected() public ¶

lastAffected( )

Returns number of affected rows in previous database operation. If no previous operation exists, this returns false.

Returns
integer
Number of affected rows
Overrides
DataSource::lastAffected()

lastError() public ¶

lastError( )

Returns a formatted error message from previous database operation.

Returns
string
Error message

lastInsertId() public ¶

lastInsertId( string $source , string $field = 'id' )

Returns the ID generated from the previous INSERT operation.

Parameters
string $source
Name of the database table
string $field optional 'id'
Name of the ID database field. Defaults to "id"
Returns
integer
Overrides
DataSource::lastInsertId()

lastNumRows() public ¶

lastNumRows( )

Returns number of rows in previous resultset. If no previous resultset exists, this returns false.

Returns
integer
Number of rows in resultset
Overrides
DataSource::lastNumRows()

length() public ¶

length( string $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
integer
An integer representing the length of the column
Overrides
DboSource::length()

limit() public ¶

limit( integer $limit , integer $offset = null )

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

Parameters
integer $limit
Limit of results returned
integer $offset optional null
Offset from which to start results
Returns
string
SQL limit/offset statement
Overrides
DboSource::limit()

listSources() public ¶

listSources( )

Returns an array of tables in the database. If there are no tables, an error is raised and the application exits.

Returns
array
Array of tablenames in the database
Overrides
DataSource::listSources()

name() public ¶

name( string $data )

Prepares field names to be quoted by parent

Parameters
string $data
Returns
string
SQL field
Overrides
DboSource::name()

renderStatement() public ¶

renderStatement( string $type , array $data )

Overrides DboSource::renderStatement to handle schema generation with Postgres-style indexes

Parameters
string $type
array $data
Returns
string
Overrides
DboSource::renderStatement()

resultSet() public ¶

resultSet( unknown_type $results )

Enter description here...

Parameters
unknown_type $results

setEncoding() public ¶

setEncoding( mixed $enc )

Sets the database encoding

Parameters
mixed $enc
Database encoding
Returns
boolean
True on success, false on failure

truncate() public ¶

truncate( mixed $table , integer $reset = 0 )

Deletes all the records in a table and drops all associated auto-increment sequences

Parameters
mixed $table
A string or model class representing the table to be truncated
integer $reset optional 0

If -1, sequences are dropped, if 0 (default), sequences are reset, and if 1, sequences are not modified

Returns
boolean
SQL TRUNCATE TABLE statement, false if not applicable.
Overrides
DboSource::truncate()

value() public ¶

value( string $data , string $column = null , boolean $read = true )

Returns a quoted and escaped string of $data for use in an SQL statement.

Parameters
string $data
String to be prepared for use in an SQL statement
string $column optional null
The column into which this data will be inserted
boolean $read optional true
Value to be used in READ or WRITE context
Returns
string
Quoted and escaped
Overrides
DboSource::value()

Methods inherited from DboSource

__construct() public ¶

__construct( array $config = null , boolean $autoConnect = true )

Constructor

Parameters
array $config optional null
Array of configuration information for the Datasource.
boolean $autoConnect optional true
Whether or not the datasource should automatically connect.
Returns
void.
Overrides
DataSource::__construct()

__filterResults() public ¶

__filterResults( array $results , object $model , array $filtered = array() )

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 optional array()
List of classes already filtered, to be skipped
Returns
array
Array of results that have been filtered through $model->afterFind

__mergeAssociation() public ¶

__mergeAssociation( unknown_type $data , unknown_type $merge , unknown_type $association , unknown_type $type , boolean $selfJoin = false )

Enter description here...

Parameters
unknown_type $data
unknown_type $merge
unknown_type $association
unknown_type $type
boolean $selfJoin optional false

__mergeConditions() public ¶

__mergeConditions( $query , $assoc )

Merges a mixed set of string/array conditions

Returns
array

__mergeHasMany() public ¶

__mergeHasMany( array $resultSet , array $merge , string $association , object $model , object $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

__parseKey() public ¶

__parseKey( Model $model , string $key , mixed $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

__quoteFields() public ¶

__quoteFields( string $conditions )

Quotes Model.fields

Parameters
string $conditions
Returns
string
or false if no match

__quoteMatchedField() public ¶

__quoteMatchedField( string $match )

Auxiliary function to quote matches Model.fields from a preg_replace_callback call

Parameters
string $match
string
Returns
string
quoted strig

__scrubQueryData() public ¶

__scrubQueryData( array $data )

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

Parameters
array $data
Returns
array

_buildFieldParameters() public ¶

_buildFieldParameters( string $columnString , array $columnData , string $position )

Build the field parameters, in a position

Parameters
string $columnString
The partially built column string
array $columnData
The array of column data.
string $position
The position type to use. 'beforeDefault' or 'afterDefault' are common
Returns
string
a built column with the field parameters added.

_constructVirtualFields() public ¶

_constructVirtualFields( Model $model , string $alias , mixed $fields )

Converts model virtual fields into sql expressions to be fetched later

Parameters
Model $model
string $alias
Alias tablename
mixed $fields
virtual fields to be used on query
Returns
array

_getJoins() public ¶

_getJoins( object $model )

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

Parameters
object $model
Returns
array

_matchRecords() public ¶

_matchRecords( Model $model , mixed $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 optional null
Returns
array
List of record IDs

_prepareUpdateFields() public ¶

_prepareUpdateFields( Model $model , array $fields , boolean $quoteValues = true , boolean $alias = false )

Quotes and prepares fields and values for an SQL UPDATE statement

Parameters
Model $model
array $fields
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
Returns
array
Fields and values, quoted and preparted

begin() public ¶

begin( model $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).


Overrides
DataSource::begin()

buildJoinStatement() public ¶

buildJoinStatement( array $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
DboSource::renderJoinStatement()
DboSource::buildStatement()

buildStatement() public ¶

buildStatement( array $query , object $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
DboSource::renderStatement()

buildTableParameters() public ¶

buildTableParameters( array $parameters , string $table = null )

Format parameters for create table

Parameters
array $parameters
string $table optional null
Returns
array

cacheMethod() public ¶

cacheMethod( string $method , string $key , mixed $value = null )

Cache 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
Name of the method being cached.
string $key
The keyname for the cache operation.
mixed $value optional null
The value to cache into memory.
Returns
mixed
Either null on failure, or the value if its set.

calculate() public ¶

calculate( model $model , string $func , array $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 optional array()
Function parameters (any values must be quoted manually)
Returns
string
An SQL calculation function

close() public ¶

close( )

Disconnects database, kills the connection and says the connection is closed.

commit() public ¶

commit( model $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).


Overrides
DataSource::commit()

conditionKeysToString() public ¶

conditionKeysToString( array $conditions , boolean $quoteValues = true , Model $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 optional true
If true, values should be quoted
Model $model optional null
A reference to the Model instance making the query
Returns
string
SQL fragment

conditions() public ¶

conditions( mixed $conditions , boolean $quoteValues = true , boolean $where = true , Model $model = null )

Creates 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
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
Returns
string
SQL fragment

create() public ¶

create( Model $model , array $fields = null , array $values = null )

The "C" in CRUD

Creates new records in the database.

Parameters
Model $model
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.

Returns
boolean
Success
Overrides
DataSource::create()

createSchema() public ¶

createSchema( object $schema , string $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 null

Optional. If specified only the table name given will be generated. Otherwise, all tables defined in the schema are generated.

Returns
string

defaultConditions() public ¶

defaultConditions( object $model , mixed $conditions , boolean $useAlias = true )

Creates 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
mixed $conditions

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
Returns
mixed
Either null, false, $conditions or an array of default conditions to use.
See
DboSource::update()
DboSource::conditions()

delete() public ¶

delete( Model $model , mixed $conditions = null )

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

Parameters
Model $model
mixed $conditions optional null
Returns
boolean
Success
Overrides
DataSource::delete()

dropSchema() public ¶

dropSchema( object $schema , string $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 null

Optional. If specified only the table name given will be generated. Otherwise, all tables defined in the schema are generated.

Returns
string

execute() public ¶

execute( string $sql , array $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 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
array $options optional array()
Returns
mixed
Resource or object representing the result set, or false on failure

expression() public ¶

expression( string $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

fetchAll() public ¶

fetchAll( string $sql , boolean $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 optional true
Enables returning/storing cached query results
$modelName optional null
Returns
array
Array of resultset rows, or false if no rows matched

fetchAssociated() public ¶

fetchAssociated( model $model , string $query , array $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

fetchRow() public ¶

fetchRow( $sql = null )

Returns a row from current resultset as an array

Returns
array
The fetched row as an array

fetchVirtualField() public ¶

fetchVirtualField( array $result )

Modifies $result array to place virtual fields in model entry where they belongs to

Parameters
array $result
$resut REference to the fetched row

field() public ¶

field( string $name , string $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
mixed
Value of field read.

flushMethodCache() public ¶

flushMethodCache( )

Empties the method caches. These caches are used by DboSource::name() and DboSource::conditions()

fullTableName() public ¶

fullTableName( mixed $model , boolean $quote = true )

Gets full table name including prefix

Parameters
mixed $model
Either a Model object or a string table name.
boolean $quote optional true
Whether you want the table name quoted.
Returns
string
Full quoted table name

generateAssociationQuery() public ¶

generateAssociationQuery( Model $model , Model $linkModel , string $type , string $association , array $assocData , array $queryData , boolean $external , array $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

getConstraint() public ¶

getConstraint( string $type , object $model , array $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 $linkModel
$association Association array
$alias
$assoc
$alias2 optional null
Returns
array
Conditions array defining the constraint between $model and $association

getLog() public ¶

getLog( boolean $sorted = false , $clear = true )

Get the query log as an array.

Parameters
boolean $sorted optional false
Get the queries sorted by time taken, defaults to false.
$clear optional true
Returns
array
Array of queries run as an array

group() public ¶

group( string $group , $model = null )

Create a GROUP BY SQL clause

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

hasAny() public ¶

hasAny( Model $Model , string $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

hasResult() public ¶

hasResult( )

Checks if the result is valid

Returns
boolean
True if the result is valid else false

identifier() public ¶

identifier( string $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

insertMulti() public ¶

insertMulti( string $table , string $fields , array $values )

Inserts multiple values into a table

Parameters
string $table
string $fields
array $values

introspectType() public ¶

introspectType( string $value )

Guesses the data type of an array

Parameters
string $value

isConnected() public ¶

isConnected( )

Checks if the source is connected to the database.

Returns
boolean
True if the database is connected, else false

logQuery() public ¶

logQuery( string $sql )

Log given SQL query.

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

order() public ¶

order( string $keys , string $direction = 'ASC' , object $model = null )

Returns an ORDER BY clause as a string.

Parameters
string $keys
$key Field reference, as a key (i.e. Post.title)
string $direction optional 'ASC'
Direction (ASC or DESC)
object $model optional null
model reference (used to look for virtual field)
Returns
string
ORDER BY clause

query() public ¶

query( )

DataSource Query abstraction

Returns
resource
Result resource identifier.

queryAssociation() public ¶

queryAssociation( Model $model , Model $linkModel , string $type , unknown_type $association , unknown_type $assocData , array $queryData , boolean $external , array $resultSet , integer $recursive , array $stack )

Queries associations. Used to fetch results on recursive models.

Parameters
Model $model
Primary Model object
Model $linkModel
Linked model that
string $type
Association type, one of the model association types ie. hasMany
unknown_type $association
unknown_type $assocData
array $queryData
boolean $external
Whether or not the association query is on an external datasource.
array $resultSet
Existing results
integer $recursive
Number of levels of association
array $stack

rawQuery() public ¶

rawQuery( string $sql )

Executes given SQL statement.

Parameters
string $sql
SQL statement
Returns
boolean

read() public ¶

read( Model $model , array $queryData = array() , integer $recursive = null )

The "R" in CRUD

Reads record(s) from the database.

Parameters
Model $model
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
Returns
mixed
boolean false on error/failure. An array of results on success.
Overrides
DataSource::read()

readTableParameters() public ¶

readTableParameters( array $name , string $table ,… )

Read additional table parameters

Parameters
array $name
$parameters
string $table ,…
Returns
array

reconnect() public ¶

reconnect( array $config = array() )

Reconnects to database server with optional new settings

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

renderJoinStatement() public ¶

renderJoinStatement( array $data )

Renders a final SQL JOIN statement

Parameters
array $data
Returns
string

resolveKey() public ¶

resolveKey( unknown_type $model , unknown_type $key , unknown_type $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 optional null
Returns
string
Overrides
DataSource::resolveKey()

rollback() public ¶

rollback( model $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).


Overrides
DataSource::rollback()

showLog() public ¶

showLog( boolean $sorted = false )

Outputs 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.

showQuery() public ¶

showQuery( string $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.

update() public ¶

update( Model $model , array $fields = array() , array $values = null , mixed $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 optional array()
array $values optional null
mixed $conditions optional null
Returns
boolean
Success
Overrides
DataSource::update()

Methods inherited from DataSource

__cacheDescription() public ¶

__cacheDescription( string $object , mixed $data = null )

Cache the DataSource description

Parameters
string $object
The name of the object (model) to cache
mixed $data optional null
The description of the model, usually a string or array
Returns
mixed

__destruct() public ¶

__destruct( )

Closes the current datasource.

insertQueryData() public ¶

insertQueryData( string $query , array $data , string $association , unknown_type $assocData , Model $model , Model $linkModel , array $stack )

Replaces {$__cakeID__$} and {$__cakeForeignKey__$} placeholders in query data.

Parameters
string $query
Query string needing replacements done.
array $data
Array of data with values that will be inserted in placeholders.
string $association
Name of association model being replaced
unknown_type $assocData
Model $model
Instance of the model to replace $cakeID$
Model $linkModel
Instance of model to replace $cakeForeignKey$
array $stack
Returns
string
String of query data with placeholders replaced.

isInterfaceSupported() public ¶

isInterfaceSupported( string $interface )

Returns true if the DataSource supports the given interface (method)

Parameters
string $interface
The name of the interface (method)
Returns
boolean
True on success

setConfig() public ¶

setConfig( array $config = array() )

Sets 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

sources() public ¶

sources( boolean $reset = false )

Convenience method for DboSource::listSources(). Returns source names in lowercase.

Parameters
boolean $reset optional false
Whether or not the source list should be reset.
Returns
array
Array of sources available in this datasource

Methods inherited from Object

Object() public ¶

Object( )

A 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()

Returns
Object

__openPersistent() public ¶

__openPersistent( string $name , string $type = null )

Open the persistent class file for reading Used by Object::_persist()

Parameters
string $name
Name of persisted class
string $type optional null
Type of persistance (e.g: registry)

_persist() public ¶

_persist( string $name , string $return , $object , $type = null )

Checks 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
name of the class to persist
string $return
$object the object to persist
$object
$type optional null
Returns
boolean
Success

_savePersistent() public ¶

_savePersistent( string $name , object $object )

You should choose a unique name for the persistent file

There are many uses for this method, see manual for examples

Parameters
string $name
name used for object to cache
object $object
the object to persist
Returns
boolean
true on save, throws error if file can not be created

_set() public ¶

_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.

Parameters
array $properties optional array()
An associative array containing properties and corresponding values.

_stop() public ¶

_stop( $status = 0 )

Stop execution of the current script. Wraps exit() making testing easier.

Parameters
$status optional 0
http://php.net/exit for values

cakeError() public ¶

cakeError( string $method , array $messages = array() )

Used 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
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
Returns
error
message

dispatchMethod() public ¶

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

Parameters
string $method
Name of the method to call
array $params optional array()
Parameter list to use when calling $method
Returns
mixed
Returns the result of the method call

log() public ¶

log( string $msg , integer $type = LOG_ERROR )

Convience method to write a message to CakeLog. See CakeLog::write() for more information on writing to logs.

Parameters
string $msg
Log message
integer $type optional LOG_ERROR
Error type constant. Defined in app/config/core.php.
Returns
boolean
Success of log write

requestAction() public ¶

requestAction( mixed $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.

Parameters
mixed $url
String or array-based url.
array $extra optional array()
if array includes the key "return" it sets the AutoRender to true.
Returns
mixed

Boolean true or false on success/failure, or contents of rendered action if 'return' is set in $extra.


toString() public ¶

toString( )

Object-to-string conversion. Each class can override this method as necessary.

Returns
string
The name of this class

Properties detail

$_baseConfig ¶

public array

Base driver configuration settings. Merged with user settings.

array(
    'persistent' => true,
    'host' => 'localhost',
    'login' => 'root',
    'password' => '',
    'database' => 'cake',
    'schema' => 'public',
    'port' => 5432,
    'encoding' => ''
)

$_commands ¶

public array

Index of basic SQL commands

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

$_sequenceMap ¶

public array

Contains mappings of custom auto-increment sequences, if a table uses a sequence name other than what is dictated by convention.

array()

$columns ¶

public array
array(
    'primary_key' => array('name' => 'serial NOT NULL'),
    'string' => array('name'  => 'varchar', 'limit' => '255'),
    'text' => array('name' => 'text'),
    'integer' => array('name' => 'integer', 'formatter' => 'intval'),
    'float' => array('name' => 'float', 'formatter' => 'floatval'),
    'datetime' => array('name' => 'timestamp', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
    'timestamp' => array('name' => 'timestamp', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
    'time' => array('name' => 'time', 'format' => 'H:i:s', 'formatter' => 'date'),
    'date' => array('name' => 'date', 'format' => 'Y-m-d', 'formatter' => 'date'),
    'binary' => array('name' => 'bytea'),
    'boolean' => array('name' => 'boolean'),
    'number' => array('name' => 'numeric'),
    'inet' => array('name'  => 'inet')
)

$description ¶

public string

Driver description

"PostgreSQL DBO Driver"

$endQuote ¶

public string

Ending Quote

'"'

$startQuote ¶

public string

Starting Quote

'"'
OpenHub
Rackspace
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (GitHub)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • Slack
  • Paid Support

Generated using CakePHP API Docs