PHP 클래스 Horde_Db_Adapter_Base, horde

저자: Mike Naberezny ([email protected])
저자: Derek DeVries ([email protected])
저자: Chuck Hagenbuch ([email protected])
상속: implements Horde_Db_Adapter
파일 보기 프로젝트 열기: horde/horde 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_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