PHP Class Horde_Db_Adapter_Base, horde

Author: Mike Naberezny ([email protected])
Author: Derek DeVries ([email protected])
Author: Chuck Hagenbuch ([email protected])
Inheritance: implements Horde_Db_Adapter
Afficher le fichier Open project: horde/horde Class Usage Examples

Protected Properties

Свойство Type Description
$_active boolean Is connection active?
$_cache Horde_Cache Cache object.
$_cachePrefix string Cache prefix.
$_config array Config options.
$_connection mixed DB connection.
$_lastQuery string The last query sent to the database.
$_logger Horde_Log_Logger Log object.
$_rowCount integer Row count of last action.
$_runtime integer Runtime of last query.
$_schema Horde_Db_Adapter_Base_Schema Schema object.
$_schemaClass string Schema class to use.
$_schemaMethods array List of schema methods.
$_transactionStarted integer Has a transaction been started?

Méthodes publiques

Méthode Description
__call ( string $method, array $args ) : mixed Delegate calls to the schema object.
__construct ( array $config ) Constructor.
__destruct ( ) Free any resources that are open.
__sleep ( ) Serialize callback.
__wakeup ( ) Unserialize callback.
adapterName ( ) : string Returns the human-readable name of the adapter. Use mixed case - one can always use downcase if needed.
addLimitOffset ( string $sql, array $options ) : string Appends LIMIT and OFFSET options to a SQL statement.
addLock ( &$sql, array $options = [] ) Appends a locking clause to an SQL statement.
cacheRead ( string $key ) : string Reads values from the cache handler.
cacheWrite ( string $key, string $value ) Writes values to the cache handler.
delete ( string $sql, mixed $arg1 = null, string $arg2 = null ) : integer Executes the delete statement and returns the number of rows affected.
disconnect ( ) Disconnect from db.
emptyInsertStatement ( string $tableName ) : string TODO
getCache ( ) : Horde_Cache
getLastQuery ( ) : string Get the last query run
getLogger ( ) return Horde_Log_Logger
getOption ( string $option ) : mixed Returns an adaptor option set through the constructor.
insertBlob ( string $table, array $fields, string $pk = null, integer $idValue = null ) : integer Inserts a row including BLOBs into a table.
insertFixture ( TODO $fixture, TODO $tableName ) : TODO Inserts the given fixture into the table. Overridden in adapters that require something beyond a simple insert (eg. Oracle).
isActive ( ) : boolean Is the connection active?
prefetchPrimaryKey ( $tableName = null ) : boolean Should primary key values be selected from their corresponding sequence before the insert statement? If true, next_sequence_value is called before each insert to set the record's primary key.
rawConnection ( ) : resource Provides access to the underlying database connection. Useful for when you need to call a proprietary method such as postgresql's lo_* methods.
reconnect ( ) Reconnect to the db.
resetRuntime ( ) : integer Reset the timer
sanitizeLimit ( $limit ) TODO
selectAll ( string $sql, mixed $arg1 = null, string $arg2 = null ) : array Returns an array of record hashes with the column names as keys and column values as values.
selectAssoc ( string $sql, mixed $arg1 = null, string $arg2 = null ) : array Returns an array where the keys are the first column of a select, and the values are the second column:
selectOne ( string $sql, mixed $arg1 = null, string $arg2 = null ) : array Returns a record hash with the column names as keys and column values as values.
selectValue ( string $sql, mixed $arg1 = null, string $arg2 = null ) : string Returns a single value from a record
selectValues ( string $sql, mixed $arg1 = null, string $arg2 = null ) : array Returns an array of the values of the first column in a select: selectValues("SELECT id FROM companies LIMIT 3") => [1,2,3]
setCache ( Horde_Cache $cache ) Set a cache object.
setLogger ( Horde_Log_Logger $logger ) Set a logger object.
supportsCountDistinct ( ) : boolean Does this adapter support using DISTINCT within COUNT? This is +true+ for all adapters except sqlite.
supportsInterval ( ) : boolean Does this adapter support using INTERVAL statements? This is +true+ for all adapters except sqlite.
supportsMigrations ( ) : boolean Does this adapter support migrations? Backend specific, as the abstract adapter always returns +false+.
transactionStarted ( ) : boolean Check if a transaction has been started.
update ( string $sql, mixed $arg1 = null, string $arg2 = null ) : integer Executes the update statement and returns the number of rows affected.
updateBlob ( string $table, array $fields, string | array $where = null ) Updates rows including BLOBs into a table.

Méthodes protégées

Méthode Description
_cacheKey ( string $key ) : string Returns the prefixed cache key to use.
_checkRequiredConfig ( array $required ) Checks if required configuration keys are present.
_formatLogEntry ( string $message, string $sql ) : string Formats the log entry.
_logError ( $error, $name, $runtime = null )
_logInfo ( string $sql, string $name, float $runtime = null ) Logs the SQL query for debugging.
_replaceParameters ( string $sql, array $args ) : string Replace ? in a SQL statement with quoted values from $args

Method Details

__call() public méthode

Delegate calls to the schema object.
public __call ( string $method, array $args ) : mixed
$method string
$args array
Résultat mixed TODO

__construct() public méthode

Constructor.
public __construct ( array $config )
$config array Configuration options and optional objects:
'charset' - (string) TODO

__destruct() public méthode

Free any resources that are open.
public __destruct ( )

__sleep() public méthode

Serialize callback.
public __sleep ( )

__wakeup() public méthode

Unserialize callback.
public __wakeup ( )

_cacheKey() protected méthode

Returns the prefixed cache key to use.
protected _cacheKey ( string $key ) : string
$key string A cache key.
Résultat string Prefixed cache key.

_checkRequiredConfig() protected méthode

Checks if required configuration keys are present.
protected _checkRequiredConfig ( array $required )
$required array Required configuration keys.

_formatLogEntry() protected méthode

Formats the log entry.
protected _formatLogEntry ( string $message, string $sql ) : string
$message string Message.
$sql string SQL statment.
Résultat string Formatted log entry.

_logError() protected méthode

protected _logError ( $error, $name, $runtime = null )

_logInfo() protected méthode

Logs the SQL query for debugging.
protected _logInfo ( string $sql, string $name, float $runtime = null )
$sql string SQL statement.
$name string TODO
$runtime float Runtime interval.

_replaceParameters() protected méthode

Replace ? in a SQL statement with quoted values from $args
protected _replaceParameters ( string $sql, array $args ) : string
$sql string SQL statement.
$args array TODO
Résultat string Modified SQL statement.

adapterName() public méthode

Returns the human-readable name of the adapter. Use mixed case - one can always use downcase if needed.
public adapterName ( ) : string
Résultat string

addLimitOffset() public méthode

Appends LIMIT and OFFSET options to a SQL statement.
public addLimitOffset ( string $sql, array $options ) : string
$sql string SQL statement.
$options array Hash with 'limit' and (optional) 'offset' values.
Résultat string

addLock() public méthode

This method *modifies* the +sql+ parameter. # SELECT * FROM suppliers FOR UPDATE add_lock! 'SELECT * FROM suppliers', :lock => true add_lock! 'SELECT * FROM suppliers', :lock => ' FOR UPDATE'
public addLock ( &$sql, array $options = [] )
$options array TODO.

cacheRead() public méthode

The key is automatically prefixed to avoid collisions when using different adapters or different configurations.
public cacheRead ( string $key ) : string
$key string A cache key.
Résultat string A value.

cacheWrite() public méthode

The key is automatically prefixed to avoid collisions when using different adapters or different configurations.
public cacheWrite ( string $key, string $value )
$key string A cache key.
$value string A value.

delete() public méthode

Executes the delete statement and returns the number of rows affected.
public delete ( string $sql, mixed $arg1 = null, string $arg2 = null ) : integer
$sql string SQL statement.
$arg1 mixed Either an array of bound parameters or a query name.
$arg2 string If $arg1 contains bound parameters, the query name.
Résultat integer Number of rows affected.

disconnect() public méthode

Disconnect from db.
public disconnect ( )

emptyInsertStatement() public méthode

TODO
public emptyInsertStatement ( string $tableName ) : string
$tableName string TODO
Résultat string TODO

getCache() public méthode

public getCache ( ) : Horde_Cache
Résultat Horde_Cache

getLastQuery() public méthode

Get the last query run
public getLastQuery ( ) : string
Résultat string

getLogger() public méthode

return Horde_Log_Logger
public getLogger ( )

getOption() public méthode

Returns an adaptor option set through the constructor.
public getOption ( string $option ) : mixed
$option string The option to return.
Résultat mixed The option value or null if option doesn't exist or is not set.

insertBlob() public méthode

Inserts a row including BLOBs into a table.
public insertBlob ( string $table, array $fields, string $pk = null, integer $idValue = null ) : integer
$table string The table name.
$fields array A hash of column names and values. BLOB columns must be provided as Horde_Db_Value_Binary objects.
$pk string The primary key column.
$idValue integer The primary key value. This parameter is required if the primary key is inserted manually.
Résultat integer Last inserted ID.

insertFixture() public méthode

Inserts the given fixture into the table. Overridden in adapters that require something beyond a simple insert (eg. Oracle).
public insertFixture ( TODO $fixture, TODO $tableName ) : TODO
$fixture TODO TODO
$tableName TODO TODO
Résultat TODO

isActive() public méthode

Is the connection active?
public isActive ( ) : boolean
Résultat boolean

prefetchPrimaryKey() public méthode

This is false for all adapters but Firebird.
Deprecation:
public prefetchPrimaryKey ( $tableName = null ) : boolean
Résultat boolean

rawConnection() public méthode

Provides access to the underlying database connection. Useful for when you need to call a proprietary method such as postgresql's lo_* methods.
public rawConnection ( ) : resource
Résultat resource

reconnect() public méthode

Reconnect to the db.
public reconnect ( )

resetRuntime() public méthode

Reset the timer
public resetRuntime ( ) : integer
Résultat integer

sanitizeLimit() public méthode

TODO
public sanitizeLimit ( $limit )

selectAll() public méthode

Returns an array of record hashes with the column names as keys and column values as values.
public selectAll ( string $sql, mixed $arg1 = null, string $arg2 = null ) : array
$sql string SQL statement.
$arg1 mixed Either an array of bound parameters or a query name.
$arg2 string If $arg1 contains bound parameters, the query name.
Résultat array

selectAssoc() public méthode

selectAssoc("SELECT id, name FROM companies LIMIT 3") => [1 => 'Ford', 2 => 'GM', 3 => 'Chrysler']
public selectAssoc ( string $sql, mixed $arg1 = null, string $arg2 = null ) : array
$sql string SQL statement.
$arg1 mixed Either an array of bound parameters or a query name.
$arg2 string If $arg1 contains bound parameters, the query name.
Résultat array

selectOne() public méthode

Returns a record hash with the column names as keys and column values as values.
public selectOne ( string $sql, mixed $arg1 = null, string $arg2 = null ) : array
$sql string SQL statement.
$arg1 mixed Either an array of bound parameters or a query name.
$arg2 string If $arg1 contains bound parameters, the query name.
Résultat array

selectValue() public méthode

Returns a single value from a record
public selectValue ( string $sql, mixed $arg1 = null, string $arg2 = null ) : string
$sql string SQL statement.
$arg1 mixed Either an array of bound parameters or a query name.
$arg2 string If $arg1 contains bound parameters, the query name.
Résultat string

selectValues() public méthode

Returns an array of the values of the first column in a select: selectValues("SELECT id FROM companies LIMIT 3") => [1,2,3]
public selectValues ( string $sql, mixed $arg1 = null, string $arg2 = null ) : array
$sql string SQL statement.
$arg1 mixed Either an array of bound parameters or a query name.
$arg2 string If $arg1 contains bound parameters, the query name.
Résultat array

setCache() public méthode

Set a cache object.
public setCache ( Horde_Cache $cache )
$cache Horde_Cache The cache object.

setLogger() public méthode

Set a logger object.
public setLogger ( Horde_Log_Logger $logger )
$logger Horde_Log_Logger

supportsCountDistinct() public méthode

Does this adapter support using DISTINCT within COUNT? This is +true+ for all adapters except sqlite.
public supportsCountDistinct ( ) : boolean
Résultat boolean

supportsInterval() public méthode

Does this adapter support using INTERVAL statements? This is +true+ for all adapters except sqlite.
public supportsInterval ( ) : boolean
Résultat boolean

supportsMigrations() public méthode

Does this adapter support migrations? Backend specific, as the abstract adapter always returns +false+.
public supportsMigrations ( ) : boolean
Résultat boolean

transactionStarted() public méthode

Check if a transaction has been started.
public transactionStarted ( ) : boolean
Résultat boolean True if transaction has been started.

update() public méthode

Executes the update statement and returns the number of rows affected.
public update ( string $sql, mixed $arg1 = null, string $arg2 = null ) : integer
$sql string SQL statement.
$arg1 mixed Either an array of bound parameters or a query name.
$arg2 string If $arg1 contains bound parameters, the query name.
Résultat integer Number of rows affected.

updateBlob() public méthode

Updates rows including BLOBs into a table.
public updateBlob ( string $table, array $fields, string | array $where = null )
$table string The table name.
$fields array A hash of column names and values. BLOB columns must be provided as Horde_Db_Value_Binary objects.
$where string | array A WHERE clause. Either a complete clause or an array containing a clause with placeholders and a list of values.

Property Details

$_active protected_oe property

Is connection active?
protected bool $_active
Résultat boolean

$_cache protected_oe property

Cache object.
protected Horde_Cache $_cache
Résultat Horde_Cache

$_cachePrefix protected_oe property

Cache prefix.
protected string $_cachePrefix
Résultat string

$_config protected_oe property

Config options.
protected array $_config
Résultat array

$_connection protected_oe property

DB connection.
protected mixed $_connection
Résultat mixed

$_lastQuery protected_oe property

The last query sent to the database.
protected string $_lastQuery
Résultat string

$_logger protected_oe property

Log object.
protected Horde_Log_Logger $_logger
Résultat Horde_Log_Logger

$_rowCount protected_oe property

Row count of last action.
protected int $_rowCount
Résultat integer

$_runtime protected_oe property

Runtime of last query.
protected int $_runtime
Résultat integer

$_schema protected_oe property

Schema object.
protected Horde_Db_Adapter_Base_Schema $_schema
Résultat Horde_Db_Adapter_Base_Schema

$_schemaClass protected_oe property

Schema class to use.
protected string $_schemaClass
Résultat string

$_schemaMethods protected_oe property

List of schema methods.
protected array $_schemaMethods
Résultat array

$_transactionStarted protected_oe property

Has a transaction been started?
protected int $_transactionStarted
Résultat integer