PHP Class Horde_Db_Adapter, horde

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

Méthodes publiques

Méthode Description
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.
beginDbTransaction ( ) Begins the transaction (and turns off auto-committing).
commitDbTransaction ( ) Commits the transaction (and turns on auto-committing).
connect ( ) Connect to the db.
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.
execute ( string $sql, mixed $arg1 = null, string $arg2 = null ) : mixed Executes the SQL statement in the context of this connection.
insert ( string $sql, array | string $arg1 = null, string $arg2 = null, string $pk = null, integer $idValue = null, string $sequenceName = null ) : integer Inserts a row into a table.
insertBlob ( string $table, array $fields, string $pk = null, integer $idValue = null ) : integer Inserts a row including BLOBs into a table.
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.
quoteString ( string $string ) : string Quotes a string, escaping any special characters.
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.
rollbackDbTransaction ( ) Rolls back the transaction (and turns on auto-committing). Must be done if the transaction block raises an exception or returns false.
select ( string $sql, mixed $arg1 = null, string $arg2 = null ) : Horde_Db_Adapter_Base_Result Returns an array of records with the column names as keys, and column values as values.
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]
supportsCountDistinct ( ) : boolean Does this adapter support using DISTINCT within COUNT? 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 $where = '' ) Updates rows including BLOBs into a table.

Method Details

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

beginDbTransaction() public méthode

Begins the transaction (and turns off auto-committing).
public beginDbTransaction ( )

commitDbTransaction() public méthode

Commits the transaction (and turns on auto-committing).
public commitDbTransaction ( )

connect() public méthode

Connect to the db.
public connect ( )

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

execute() public méthode

Executes the SQL statement in the context of this connection.
Deprecation: Deprecated for external usage. Use select() instead.
public execute ( string $sql, mixed $arg1 = null, string $arg2 = null ) : mixed
$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 mixed

insert() public méthode

Inserts a row into a table.
public insert ( string $sql, array | string $arg1 = null, string $arg2 = null, string $pk = null, integer $idValue = null, string $sequenceName = null ) : integer
$sql string SQL statement.
$arg1 array | string Either an array of bound parameters or a query name.
$arg2 string If $arg1 contains bound parameters, the query name.
$pk string The primary key column.
$idValue integer The primary key value. This parameter is required if the primary key is inserted manually.
$sequenceName string The sequence name.
Résultat integer Last inserted ID.

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.

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.
public prefetchPrimaryKey ( $tableName = null ) : boolean
Résultat boolean

quoteString() public méthode

Quotes a string, escaping any special characters.
public quoteString ( string $string ) : string
$string string
Résultat string

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

rollbackDbTransaction() public méthode

Rolls back the transaction (and turns on auto-committing). Must be done if the transaction block raises an exception or returns false.

select() public méthode

Returns an array of records with the column names as keys, and column values as values.
public select ( string $sql, mixed $arg1 = null, string $arg2 = null ) : Horde_Db_Adapter_Base_Result
$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 Horde_Db_Adapter_Base_Result

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

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

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 $where = '' )
$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 A WHERE clause.