Overview

Packages

  • Db
    • Adapter
    • Migration

Classes

  • Horde_Db_Adapter_Base
  • Horde_Db_Adapter_Base_Column
  • Horde_Db_Adapter_Base_ColumnDefinition
  • Horde_Db_Adapter_Base_Index
  • Horde_Db_Adapter_Base_Schema
  • Horde_Db_Adapter_Base_Table
  • Horde_Db_Adapter_Base_TableDefinition
  • Horde_Db_Adapter_Mysql
  • Horde_Db_Adapter_Mysql_Column
  • Horde_Db_Adapter_Mysql_Result
  • Horde_Db_Adapter_Mysql_Schema
  • Horde_Db_Adapter_Mysqli
  • Horde_Db_Adapter_Mysqli_Result
  • Horde_Db_Adapter_Pdo_Base
  • Horde_Db_Adapter_Pdo_Mysql
  • Horde_Db_Adapter_Pdo_Pgsql
  • Horde_Db_Adapter_Pdo_Sqlite
  • Horde_Db_Adapter_Postgresql_Column
  • Horde_Db_Adapter_Postgresql_Schema
  • Horde_Db_Adapter_SplitRead
  • Horde_Db_Adapter_Sqlite_Column
  • Horde_Db_Adapter_Sqlite_Schema

Interfaces

  • Horde_Db_Adapter
  • Overview
  • Package
  • Class
  • Tree

Class Horde_Db_Adapter_Base

Horde_Db_Adapter_Base implements Horde_Db_Adapter

Direct known subclasses

Horde_Db_Adapter_Mysql, Horde_Db_Adapter_Mysqli, Horde_Db_Adapter_Pdo_Base

Indirect known subclasses

Horde_Db_Adapter_Pdo_Mysql, Horde_Db_Adapter_Pdo_Pgsql, Horde_Db_Adapter_Pdo_Sqlite
Abstract
Package: Db\Adapter
Category: Horde
License: http://www.horde.org/licenses/bsd
Author: Mike Naberezny mike@maintainable.com
Author: Derek DeVries derek@maintainable.com
Author: Chuck Hagenbuch chuck@horde.org
Located at Horde/Db/Adapter/Base.php
Methods summary
public
# __construct( array $config )

Constructor.

Constructor.

Parameters

$config
Configuration options and optional objects: <span class="php-quote">'charset'</span> - (string) TODO
public
# __destruct( )

Free any resources that are open.

Free any resources that are open.

public
# __sleep( )

Serialize callback.

Serialize callback.

public
# __wakeup( )

Unserialize callback.

Unserialize callback.

public mixed
# getOption( string $option )

Returns an adaptor option set through the constructor.

Returns an adaptor option set through the constructor.

Parameters

$option
The option to return.

Returns

mixed

The option value or null if option doesn't exist or is not set.

public
# setCache( Horde_Cache $cache )

Set a cache object.

Set a cache object.

Inject

Var

Horde_Cache $logger The cache object.
public Horde_Cache
# getCache( )

Returns

Horde_Cache
public
# setLogger( Horde_Log_Logger $logger )

Set a logger object.

Set a logger object.

Inject

Var

Horde_Log_Logger $logger The logger object.
public
# getLogger( )

return Horde_Log_Logger

return Horde_Log_Logger

public mixed
# __call( string $method, array $args )

Delegate calls to the schema object.

Delegate calls to the schema object.

Parameters

$method
$args

Returns

mixed
TODO

Throws

BadMethodCallException
public string
# adapterName( )

Returns the human-readable name of the adapter. Use mixed case - one can always use downcase if needed.

Returns the human-readable name of the adapter. Use mixed case - one can always use downcase if needed.

Returns

string

Implementation of

Horde_Db_Adapter::adapterName()
public boolean
# supportsMigrations( )

Does this adapter support migrations? Backend specific, as the abstract adapter always returns +false+.

Does this adapter support migrations? Backend specific, as the abstract adapter always returns +false+.

Returns

boolean

Implementation of

Horde_Db_Adapter::supportsMigrations()
public boolean
# supportsCountDistinct( )

Does this adapter support using DISTINCT within COUNT? This is +true+ for all adapters except sqlite.

Does this adapter support using DISTINCT within COUNT? This is +true+ for all adapters except sqlite.

Returns

boolean

Implementation of

Horde_Db_Adapter::supportsCountDistinct()
public boolean
# prefetchPrimaryKey( mixed $tableName = null )

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. This is false for all adapters but Firebird.

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. This is false for all adapters but Firebird.

Returns

boolean

Implementation of

Horde_Db_Adapter::prefetchPrimaryKey()
public string
# getLastQuery( )

Get the last query run

Get the last query run

Returns

string
public integer
# resetRuntime( )

Reset the timer

Reset the timer

Returns

integer
public boolean
# isActive( )

Is the connection active?

Is the connection active?

Returns

boolean

Implementation of

Horde_Db_Adapter::isActive()
public
# reconnect( )

Reconnect to the db.

Reconnect to the db.

Implementation of

Horde_Db_Adapter::reconnect()
public
# disconnect( )

Disconnect from db.

Disconnect from db.

Implementation of

Horde_Db_Adapter::disconnect()
public resource
# rawConnection( )

Provides access to the underlying database connection. Useful for when you need to call a proprietary method such as postgresql's lo_* methods.

Provides access to the underlying database connection. Useful for when you need to call a proprietary method such as postgresql's lo_* methods.

Returns

resource

Implementation of

Horde_Db_Adapter::rawConnection()
public PDOStatement
# select( string $sql, mixed $arg1 = null, string $arg2 = null )

Returns an array of records with the column names as keys, and column values as values.

Returns an array of records with the column names as keys, and column values as values.

Parameters

$sql
SQL statement.
$arg1
<p>Either an array of bound parameters or a query name.</p>
$arg2
<p>If $arg1 contains bound parameters, the query name.</p>

Returns

PDOStatement

Throws

Horde_Db_Exception

Implementation of

Horde_Db_Adapter::select()
public array
# selectAll( string $sql, mixed $arg1 = null, string $arg2 = null )

Returns an array of record hashes with the column names as keys and column values as values.

Returns an array of record hashes with the column names as keys and column values as values.

Parameters

$sql
SQL statement.
$arg1
<p>Either an array of bound parameters or a query name.</p>
$arg2
<p>If $arg1 contains bound parameters, the query name.</p>

Returns

array

Throws

Horde_Db_Exception

Implementation of

Horde_Db_Adapter::selectAll()
public array
# selectOne( string $sql, mixed $arg1 = null, string $arg2 = null )

Returns a record hash with the column names as keys and column values as values.

Returns a record hash with the column names as keys and column values as values.

Parameters

$sql
SQL statement.
$arg1
<p>Either an array of bound parameters or a query name.</p>
$arg2
<p>If $arg1 contains bound parameters, the query name.</p>

Returns

array

Throws

Horde_Db_Exception

Implementation of

Horde_Db_Adapter::selectOne()
public string
# selectValue( string $sql, mixed $arg1 = null, string $arg2 = null )

Returns a single value from a record

Returns a single value from a record

Parameters

$sql
SQL statement.
$arg1
<p>Either an array of bound parameters or a query name.</p>
$arg2
<p>If $arg1 contains bound parameters, the query name.</p>

Returns

string

Throws

Horde_Db_Exception

Implementation of

Horde_Db_Adapter::selectValue()
public array
# selectValues( string $sql, mixed $arg1 = null, string $arg2 = null )

Returns an array of the values of the first column in a select: selectValues("SELECT id FROM companies LIMIT 3") => [1,2,3]

Returns an array of the values of the first column in a select: selectValues("SELECT id FROM companies LIMIT 3") => [1,2,3]

Parameters

$sql
SQL statement.
$arg1
<p>Either an array of bound parameters or a query name.</p>
$arg2
<p>If $arg1 contains bound parameters, the query name.</p>

Returns

array

Throws

Horde_Db_Exception

Implementation of

Horde_Db_Adapter::selectValues()
public array
# selectAssoc( string $sql, mixed $arg1 = null, string $arg2 = null )

Returns an array where the keys are the first column of a select, and the values are the second column:

Returns an array where the keys are the first column of a select, and the values are the second column:

selectAssoc("SELECT id, name FROM companies LIMIT 3") => [1 => 'Ford', 2 => 'GM', 3 => 'Chrysler']

Parameters

$sql
SQL statement.
$arg1
<p>Either an array of bound parameters or a query name.</p>
$arg2
<p>If $arg1 contains bound parameters, the query name.</p>

Returns

array

Throws

Horde_Db_Exception

Implementation of

Horde_Db_Adapter::selectAssoc()
public PDOStatement
# execute( string $sql, mixed $arg1 = null, string $arg2 = null )

Executes the SQL statement in the context of this connection.

Executes the SQL statement in the context of this connection.

Parameters

$sql
SQL statement.
$arg1
<p>Either an array of bound parameters or a query name.</p>
$arg2
<p>If $arg1 contains bound parameters, the query name.</p>

Returns

PDOStatement

Throws

Horde_Db_Exception

Implementation of

Horde_Db_Adapter::execute()
public integer
# insert( string $sql, array|string $arg1 = null, string $arg2 = null, string $pk = null, integer $idValue = null, string $sequenceName = null )

Inserts a row into a table.

Inserts a row into a table.

Parameters

$sql
SQL statement.
$arg1
<p>Either an array of bound parameters or a query name.</p>
$arg2
<p>If $arg1 contains bound parameters, the query name.</p>
$pk
The primary key column.
$idValue
<p>The primary key value. This parameter is required if the primary key is inserted manually.</p>
$sequenceName
The sequence name.

Returns

integer
Last inserted ID.

Throws

Horde_Db_Exception

Implementation of

Horde_Db_Adapter::insert()
public integer
# update( string $sql, mixed $arg1 = null, string $arg2 = null )

Executes the update statement and returns the number of rows affected.

Executes the update statement and returns the number of rows affected.

Parameters

$sql
SQL statement.
$arg1
<p>Either an array of bound parameters or a query name.</p>
$arg2
<p>If $arg1 contains bound parameters, the query name.</p>

Returns

integer
Number of rows affected.

Throws

Horde_Db_Exception

Implementation of

Horde_Db_Adapter::update()
public integer
# delete( string $sql, mixed $arg1 = null, string $arg2 = null )

Executes the delete statement and returns the number of rows affected.

Executes the delete statement and returns the number of rows affected.

Parameters

$sql
SQL statement.
$arg1
<p>Either an array of bound parameters or a query name.</p>
$arg2
<p>If $arg1 contains bound parameters, the query name.</p>

Returns

integer
Number of rows affected.

Throws

Horde_Db_Exception

Implementation of

Horde_Db_Adapter::delete()
public boolean
# transactionStarted( )

Check if a transaction has been started.

Check if a transaction has been started.

Returns

boolean
True if transaction has been started.

Implementation of

Horde_Db_Adapter::transactionStarted()
public
# beginDbTransaction( )

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

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

Implementation of

Horde_Db_Adapter::beginDbTransaction()
public
# commitDbTransaction( )

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

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

Implementation of

Horde_Db_Adapter::commitDbTransaction()
public
# rollbackDbTransaction( )

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

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

Implementation of

Horde_Db_Adapter::rollbackDbTransaction()
public string
# addLimitOffset( string $sql, array $options )

Appends LIMIT and OFFSET options to a SQL statement.

Appends LIMIT and OFFSET options to a SQL statement.

Parameters

$sql
SQL statement.
$options
Hash with 'limit' and (optional) 'offset' values.

Returns

string

Implementation of

Horde_Db_Adapter::addLimitOffset()
public
# sanitizeLimit( mixed $limit )

TODO

TODO

public
# addLock( string & $sql, array $options = array() )

Appends a locking clause to an SQL statement. This method modifies the +sql+ parameter.

Appends a locking clause to an SQL statement. 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'

Parameters

$sql
$sql SQL statment.
$options
TODO.

Implementation of

Horde_Db_Adapter::addLock()
public TODO
# insertFixture( TODO $fixture, TODO $tableName )

Inserts the given fixture into the table. Overridden in adapters that require something beyond a simple insert (eg. Oracle).

Inserts the given fixture into the table. Overridden in adapters that require something beyond a simple insert (eg. Oracle).

Parameters

$fixture
TODO
$tableName
TODO

Returns

TODO
public string
# emptyInsertStatement( string $tableName )

TODO

TODO

Parameters

$tableName
TODO

Returns

string
TODO
Methods inherited from Horde_Db_Adapter
connect(), quoteString()
API documentation generated by ApiGen