PHP Класс Horde_Db_Adapter_Base, horde

Автор: Mike Naberezny ([email protected])
Автор: Derek DeVries ([email protected])
Автор: Chuck Hagenbuch ([email protected])
Наследование: implements Horde_Db_Adapter
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$_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?

Открытые методы

Метод Описание
__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.

Защищенные методы

Метод Описание
_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

Описание методов

__call() публичный Метод

Delegate calls to the schema object.
public __call ( string $method, array $args ) : mixed
$method string
$args array
Результат mixed TODO

__construct() публичный Метод

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

__destruct() публичный Метод

Free any resources that are open.
public __destruct ( )

__sleep() публичный Метод

Serialize callback.
public __sleep ( )

__wakeup() публичный Метод

Unserialize callback.
public __wakeup ( )

_cacheKey() защищенный Метод

Returns the prefixed cache key to use.
protected _cacheKey ( string $key ) : string
$key string A cache key.
Результат string Prefixed cache key.

_checkRequiredConfig() защищенный Метод

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

_formatLogEntry() защищенный Метод

Formats the log entry.
protected _formatLogEntry ( string $message, string $sql ) : string
$message string Message.
$sql string SQL statment.
Результат string Formatted log entry.

_logError() защищенный Метод

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

_logInfo() защищенный Метод

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() защищенный Метод

Replace ? in a SQL statement with quoted values from $args
protected _replaceParameters ( string $sql, array $args ) : string
$sql string SQL statement.
$args array TODO
Результат string Modified SQL statement.

adapterName() публичный Метод

Returns the human-readable name of the adapter. Use mixed case - one can always use downcase if needed.
public adapterName ( ) : string
Результат string

addLimitOffset() публичный Метод

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.
Результат string

addLock() публичный Метод

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() публичный Метод

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.
Результат string A value.

cacheWrite() публичный Метод

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() публичный Метод

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.
Результат integer Number of rows affected.

disconnect() публичный Метод

Disconnect from db.
public disconnect ( )

emptyInsertStatement() публичный Метод

TODO
public emptyInsertStatement ( string $tableName ) : string
$tableName string TODO
Результат string TODO

getCache() публичный Метод

public getCache ( ) : Horde_Cache
Результат Horde_Cache

getLastQuery() публичный Метод

Get the last query run
public getLastQuery ( ) : string
Результат string

getLogger() публичный Метод

return Horde_Log_Logger
public getLogger ( )

getOption() публичный Метод

Returns an adaptor option set through the constructor.
public getOption ( string $option ) : mixed
$option string The option to return.
Результат mixed The option value or null if option doesn't exist or is not set.

insertBlob() публичный Метод

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.
Результат integer Last inserted ID.

insertFixture() публичный Метод

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
Результат TODO

isActive() публичный Метод

Is the connection active?
public isActive ( ) : boolean
Результат boolean

prefetchPrimaryKey() публичный Метод

This is false for all adapters but Firebird.
Устаревший:
public prefetchPrimaryKey ( $tableName = null ) : boolean
Результат boolean

rawConnection() публичный Метод

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
Результат resource

reconnect() публичный Метод

Reconnect to the db.
public reconnect ( )

resetRuntime() публичный Метод

Reset the timer
public resetRuntime ( ) : integer
Результат integer

sanitizeLimit() публичный Метод

TODO
public sanitizeLimit ( $limit )

selectAll() публичный Метод

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.
Результат array

selectAssoc() публичный Метод

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.
Результат array

selectOne() публичный Метод

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.
Результат array

selectValue() публичный Метод

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.
Результат string

selectValues() публичный Метод

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.
Результат array

setCache() публичный Метод

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

setLogger() публичный Метод

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

supportsCountDistinct() публичный Метод

Does this adapter support using DISTINCT within COUNT? This is +true+ for all adapters except sqlite.
public supportsCountDistinct ( ) : boolean
Результат boolean

supportsInterval() публичный Метод

Does this adapter support using INTERVAL statements? This is +true+ for all adapters except sqlite.
public supportsInterval ( ) : boolean
Результат boolean

supportsMigrations() публичный Метод

Does this adapter support migrations? Backend specific, as the abstract adapter always returns +false+.
public supportsMigrations ( ) : boolean
Результат boolean

transactionStarted() публичный Метод

Check if a transaction has been started.
public transactionStarted ( ) : boolean
Результат boolean True if transaction has been started.

update() публичный Метод

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.
Результат integer Number of rows affected.

updateBlob() публичный Метод

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.

Описание свойств

$_active защищенное свойство

Is connection active?
protected bool $_active
Результат boolean

$_cache защищенное свойство

Cache object.
protected Horde_Cache $_cache
Результат Horde_Cache

$_cachePrefix защищенное свойство

Cache prefix.
protected string $_cachePrefix
Результат string

$_config защищенное свойство

Config options.
protected array $_config
Результат array

$_connection защищенное свойство

DB connection.
protected mixed $_connection
Результат mixed

$_lastQuery защищенное свойство

The last query sent to the database.
protected string $_lastQuery
Результат string

$_logger защищенное свойство

Log object.
protected Horde_Log_Logger $_logger
Результат Horde_Log_Logger

$_rowCount защищенное свойство

Row count of last action.
protected int $_rowCount
Результат integer

$_runtime защищенное свойство

Runtime of last query.
protected int $_runtime
Результат integer

$_schema защищенное свойство

Schema object.
protected Horde_Db_Adapter_Base_Schema $_schema
Результат Horde_Db_Adapter_Base_Schema

$_schemaClass защищенное свойство

Schema class to use.
protected string $_schemaClass
Результат string

$_schemaMethods защищенное свойство

List of schema methods.
protected array $_schemaMethods
Результат array

$_transactionStarted защищенное свойство

Has a transaction been started?
protected int $_transactionStarted
Результат integer