## Zend_Db_Adapter_Abstract

Description

Class for connecting to SQL databases and performing common operations.

- abstract:
- license: New BSD License
- copyright: Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)

Located in /Zend/Db/Adapter/Abstract.php (line 40)

Direct descendents

Class | Description
--- | ---
Zend_Db_Adapter_Db2 |
Zend_Db_Adapter_Oracle |
Zend_Db_Adapter_Pdo_Abstract | Class for connecting to SQL databases and performing common operations using PDO.

Variable Summary
array $_config
object|resource|null $_connection
integer $_fetchMode
Zend_Db_Profiler $_profiler
Method Summary
void __construct (array $config)
bool beginTransaction ()
bool commit ()
int delete (string $table, string $where)
array describeTable (string $tableName, [string $schemaName = null])
array fetchAll (string|Zend_Db_Select $sql, [array $bind = array()])
string fetchAssoc (string|Zend_Db_Select $sql, [array $bind = array()])
array fetchCol (string|Zend_Db_Select $sql, [array $bind = array()])
string fetchOne (string|Zend_Db_Select $sql, [array $bind = array()])
string fetchPairs (string|Zend_Db_Select $sql, [array $bind = array()])
array fetchRow (string|Zend_Db_Select $sql, [array $bind = array()])
object|resource|null getConnection ()
int getFetchMode ()
Zend_Db_Profiler getProfiler ()
string getQuoteIdentifierSymbol ()
int insert (string $table, array $bind)
integer lastInsertId ([string $sequenceName = null])
string limit (mixed $sql, integer $count, [integer $offset = 0])
array listTables ()
Zend_Db_Statment|PDOStatement prepare (string|Zend_Db_Select $sql)
Zend_Db_Statement query (string|Zend_Db_Select $sql, [array $bind = array()])
mixed quote (mixed $value)
string quoteIdentifier (string|Zend_Db_Expr $ident)
mixed quoteInto (string $text, mixed $value)
bool rollBack ()
Zend_Db_Select select ()
void setFetchMode (integer $mode)
int update (string $table, array $bind, string $where)
void _beginTransaction ()
void _commit ()
void _connect ()
string _quote (string $value)
void _rollBack ()
Variables
array $_config = array() (line 48)

User-provided configuration

- access: protected

Redefined in descendants as:

- Zend_Db_Adapter_Db2::$_config : User-provided configuration.
- Zend_Db_Adapter_Oracle::$_config : User-provided configuration.

object|resource|null $_connection = null (line 69)

Database connection

- access: protected

integer $_fetchMode = Zend_Db::FETCH_ASSOC (line 55)

Fetch mode

- access: protected

Zend_Db_Profiler $_profiler (line 62)

Query profiler

- access: protected

Methods
Constructor __construct (line 86)

Constructor.

$config is an array of key/value pairs containing configuration options. These options are common to most adapters:

dbname => (string) The name of the database to user (required) username => (string) Connect to the database as this username (optional). password => (string) Password associated with the username (optional). host => (string) What host to connect to (default 127.0.0.1).

- access: public
- throws: Zend_Db_Adapter_Exception

void __construct (array $config)

- array $config: An array of configuration keys.

Redefined in descendants as:

- Zend_Db_Adapter_Db2::__construct() : Constructor.
- Zend_Db_Adapter_Oracle::__construct() : Constructor.
- Zend_Db_Adapter_Pdo_Sqlite::__construct() : Constructor.

beginTransaction (line 166)

Leave autocommit mode and begin a transaction.

- return: True
- access: public

bool beginTransaction ()
commit (line 180)

Commit a transaction and return to autocommit mode.

- return: True
- access: public

bool commit ()
delete (line 260)

Deletes table rows based on a WHERE clause.

- return: The number of affected rows.
- access: public

int delete (string $table, string $where)

- string $table: The table to udpate.
- string $where: DELETE WHERE clause.

describeTable (line 506)

Returns the column descriptions for a table.

The return value is an associative array keyed by the column name, as returned by the RDBMS.

The value of each array element is an associative array with the following keys:

SCHEMA_NAME => string; name of database or schema TABLE_NAME => string; COLUMN_NAME => string; column name COLUMN_POSITION => number; ordinal position of column in table DATA_TYPE => string; SQL datatype name of column DEFAULT => string; default expression of column, null if none NULLABLE => boolean; true if column can have nulls LENGTH => number; length of CHAR/VARCHAR SCALE => number; scale of NUMERIC/DECIMAL PRECISION => number; precision of NUMERIC/DECIMAL UNSIGNED => boolean; unsigned property of an integer type PRIMARY => boolean; true if column is part of the primary key

- access: public
- abstract:

array describeTable (string $tableName, [string $schemaName = null])

- string $tableName
- string $schemaName: OPTIONAL

Redefined in descendants as:

- Zend_Db_Adapter_Db2::describeTable() : Returns the column descriptions for a table.
- Zend_Db_Adapter_Oracle::describeTable() : Returns the column descriptions for a table.
- Zend_Db_Adapter_Pdo_Mssql::describeTable() : Returns the column descriptions for a table.
- Zend_Db_Adapter_Pdo_Mysql::describeTable() : Returns the column descriptions for a table.
- Zend_Db_Adapter_Pdo_Oci::describeTable() : Returns the column descriptions for a table.
- Zend_Db_Adapter_Pdo_Pgsql::describeTable() : Returns the column descriptions for a table.
- Zend_Db_Adapter_Pdo_Sqlite::describeTable() : Returns the column descriptions for a table.

fetchAll (line 300)

Fetches all SQL result rows as a sequential array.

Uses the current fetchMode for the adapter.

- access: public

array fetchAll (string|Zend_Db_Select $sql, [array $bind = array()])

- string|Zend_Db_Select $sql: An SQL SELECT statement.
- array $bind: Data to bind into SELECT placeholders.

fetchAssoc (line 317)

Fetches all SQL result rows as an associative array.

The first column is the key, the entire row array is the value.

- access: public

string fetchAssoc (string|Zend_Db_Select $sql, [array $bind = array()])

- string|Zend_Db_Select $sql: An SQL SELECT statement.
- array $bind: Data to bind into SELECT placeholders.

fetchCol (line 337)

Fetches the first column of all SQL result rows as an array.

The first column in each row is used as the array key.

- access: public

array fetchCol (string|Zend_Db_Select $sql, [array $bind = array()])

- string|Zend_Db_Select $sql: An SQL SELECT statement.
- array $bind: Data to bind into SELECT placeholders.

fetchOne (line 371)

Fetches the first column of the first row of the SQL result.

- access: public

string fetchOne (string|Zend_Db_Select $sql, [array $bind = array()])

- string|Zend_Db_Select $sql: An SQL SELECT statement.
- array $bind: Data to bind into SELECT placeholders.

fetchPairs (line 354)

Fetches all SQL result rows as an array of key-value pairs.

The first column is the key, the second column is the value.

- access: public

string fetchPairs (string|Zend_Db_Select $sql, [array $bind = array()])

- string|Zend_Db_Select $sql: An SQL SELECT statement.
- array $bind: Data to bind into SELECT placeholders.

fetchRow (line 386)

Fetches the first row of the SQL result.

Uses the current fetchMode for the adapter.

- access: public

array fetchRow (string|Zend_Db_Select $sql, [array $bind = array()])

- string|Zend_Db_Select $sql: An SQL SELECT statement.
- array $bind: Data to bind into SELECT placeholders.

getConnection (line 117)

Returns the underlying database connection object or resource.

If not presently connected, this initiates the connection.

- access: public

object|resource|null getConnection ()
getFetchMode (line 287)

Get the fetch mode.

- access: public

int getFetchMode ()
getProfiler (line 128)

Returns the profiler for this adapter.

- access: public

Zend_Db_Profiler getProfiler ()
getQuoteIdentifierSymbol (line 464)

Returns the symbol the adapter uses for delimited identifiers.

- access: public

string getQuoteIdentifierSymbol ()

Redefined in descendants as:

- Zend_Db_Adapter_Db2::getQuoteIdentifierSymbol()
- Zend_Db_Adapter_Pdo_Mssql::getQuoteIdentifierSymbol()
- Zend_Db_Adapter_Pdo_Mysql::getQuoteIdentifierSymbol()

insert (line 210)

Inserts a table row with specified data.

- return: The number of affected rows.
- access: public

int insert (string $table, array $bind)

- string $table: The table to insert data into.
- array $bind: Column-value pairs.

Redefined in descendants as:

- Zend_Db_Adapter_Db2::insert() : Inserts a table row with specified data.

lastInsertId (line 537)

Gets the last inserted ID.

- access: public
- abstract:

integer lastInsertId ([string $sequenceName = null])

- string $sequenceName: Name of sequence from which to get the last value generated.

Redefined in descendants as:

- Zend_Db_Adapter_Db2::lastInsertId() : Gets the last inserted ID.
- Zend_Db_Adapter_Oracle::lastInsertId() : Gets the last inserted ID.
- Zend_Db_Adapter_Pdo_Abstract::lastInsertId() : Gets the last inserted ID.
- Zend_Db_Adapter_Pdo_Mssql::lastInsertId() : Gets the last inserted ID.
- Zend_Db_Adapter_Pdo_Oci::lastInsertId() : Gets the last inserted ID.
- Zend_Db_Adapter_Pdo_Pgsql::lastInsertId() : Gets the last inserted ID.

limit (line 569)

Adds an adapter-specific LIMIT clause to the SELECT statement.

- access: public
- abstract:

string limit (mixed $sql, integer $count, integer $offset)

- mixed $sql
- integer $count
- integer $offset

Redefined in descendants as:

- Zend_Db_Adapter_Db2::limit() : Adds an adapter-specific LIMIT clause to the SELECT statement.
- Zend_Db_Adapter_Oracle::limit() : Adds an adapter-specific LIMIT clause to the SELECT statement.
- Zend_Db_Adapter_Pdo_Mssql::limit() : Adds an adapter-specific LIMIT clause to the SELECT statement.
- Zend_Db_Adapter_Pdo_Mysql::limit() : Adds an adapter-specific LIMIT clause to the SELECT statement.
- Zend_Db_Adapter_Pdo_Oci::limit() : Adds an adapter-specific LIMIT clause to the SELECT statement.
- Zend_Db_Adapter_Pdo_Pgsql::limit() : Adds an adapter-specific LIMIT clause to the SELECT statement.
- Zend_Db_Adapter_Pdo_Sqlite::limit() : Adds an adapter-specific LIMIT clause to the SELECT statement.

listTables (line 478)

Returns a list of the tables in the database.

- access: public
- abstract:

array listTables ()

Redefined in descendants as:

- Zend_Db_Adapter_Db2::listTables() : Returns a list of the tables in the database.
- Zend_Db_Adapter_Oracle::listTables() : Returns a list of the tables in the database.
- Zend_Db_Adapter_Pdo_Mssql::listTables() : Returns a list of the tables in the database.
- Zend_Db_Adapter_Pdo_Mysql::listTables() : Returns a list of the tables in the database.
- Zend_Db_Adapter_Pdo_Oci::listTables() : Returns a list of the tables in the database.
- Zend_Db_Adapter_Pdo_Pgsql::listTables() : Returns a list of the tables in the database.
- Zend_Db_Adapter_Pdo_Sqlite::listTables() : Returns a list of the tables in the database.

prepare (line 529)

Prepare a statement and return a PDOStatement-like object.

- access: public
- abstract:

Zend_Db_Statment|PDOStatement prepare (string|Zend_Db_Select $sql)

- string|Zend_Db_Select $sql: SQL query

Redefined in descendants as:

- Zend_Db_Adapter_Db2::prepare() : Returns an SQL statement for preparation.
- Zend_Db_Adapter_Oracle::prepare() : Returns an SQL statement for preparation.
- Zend_Db_Adapter_Pdo_Abstract::prepare() : Prepares an SQL statement.

query (line 140)

Prepares and executes an SQL statement with bound data.

- return: (may also be PDOStatement in the case of PDO)
- access: public

Zend_Db_Statement query (string|Zend_Db_Select $sql, [array $bind = array()])

- string|Zend_Db_Select $sql: The SQL statement with placeholders.
- array $bind: An array of data to bind to the placeholders.

Redefined in descendants as:

- Zend_Db_Adapter_Pdo_Abstract::query() : Special handling for PDO query().

quote (line 402)

Safely quotes a value for an SQL statement.

If an array is passed as the value, the array values are quoted and then returned as a comma-separated string.

- return: An SQL-safe quoted value (or string of separated values).
- access: public

mixed quote (mixed $value)

- mixed $value: The value to quote.

quoteIdentifier (line 449)

Quotes an identifier.

- return: The quoted identifier.
- access: public

string quoteIdentifier (string|Zend_Db_Expr $ident)

- string|Zend_Db_Expr $ident: The identifier.

Redefined in descendants as:

- Zend_Db_Adapter_Pdo_Mssql::quoteIdentifier() : Quotes an identifier.

quoteInto (line 438)

Quotes a value and places into a piece of text at a placeholder.

The placeholder is a question-mark; all placeholders will be replaced with the quoted value. For example:

1. $text = "WHERE date < ?";
2. $date = "2005-01-02";
3. $safe = $sql->quoteInto($text, $date);

- return: An SQL-safe quoted value placed into the orignal text.
- access: public

mixed quoteInto (string $text, mixed $value)

- string $text: The text with a placeholder.
- mixed $value: The value to quote.

rollBack (line 194)

Roll back a transaction and return to autocommit mode.

- return: True
- access: public

bool rollBack ()
select (line 277)

Creates and returns a new Zend_Db_Select object for this adapter.

- access: public

Zend_Db_Select select ()
setFetchMode (line 559)

Set the fetch mode.

- access: public
- abstract:

void setFetchMode (integer $mode)

- integer $mode

Redefined in descendants as:

- Zend_Db_Adapter_Db2::setFetchMode() : Set the fetch mode.
- Zend_Db_Adapter_Oracle::setFetchMode() : Set the fetch mode.
- Zend_Db_Adapter_Pdo_Abstract::setFetchMode() : Set the PDO fetch mode.

update (line 234)

Updates table rows with specified data based on a WHERE clause.

- return: The number of affected rows.
- access: public

int update (string $table, array $bind, string $where)

- string $table: The table to udpate.
- array $bind: Column-value pairs.
- string $where: UPDATE WHERE clause.

Redefined in descendants as:

- Zend_Db_Adapter_Db2::update() : Updates table rows with specified data based on a WHERE clause.

_beginTransaction (line 542)

Begin a transaction.

- access: protected
- abstract:

void _beginTransaction ()

Redefined in descendants as:

- Zend_Db_Adapter_Db2::_beginTransaction() : Begin a transaction.
- Zend_Db_Adapter_Oracle::_beginTransaction() : Leave autocommit mode and begin a transaction.
- Zend_Db_Adapter_Pdo_Abstract::_beginTransaction() : Begin a transaction.

_commit (line 547)

Commit a transaction.

- access: protected
- abstract:

void _commit ()

Redefined in descendants as:

- Zend_Db_Adapter_Db2::_commit() : Commit a transaction.
- Zend_Db_Adapter_Oracle::_commit() : Commit a transaction and return to autocommit mode.
- Zend_Db_Adapter_Pdo_Abstract::_commit() : Commit a transaction.

_connect (line 521)

Creates a connection to the database.

- access: protected
- abstract:

void _connect ()

Redefined in descendants as:

- Zend_Db_Adapter_Db2::_connect() : Creates a connection resource.
- Zend_Db_Adapter_Oracle::_connect() : Creates a connection resource.
- Zend_Db_Adapter_Pdo_Abstract::_connect() : Creates a PDO object and connects to the database.

_quote (line 514)

Quote a raw string.

- return: Quoted string
- access: protected
- abstract:

string _quote (string $value)

- string $value: Raw string

Redefined in descendants as:

- Zend_Db_Adapter_Db2::_quote() : Quote a raw string.
- Zend_Db_Adapter_Oracle::_quote() : Quote a raw string.
- Zend_Db_Adapter_Pdo_Abstract::_quote() : Quote a raw string.
- Zend_Db_Adapter_Pdo_Oci::_quote() : Quote a raw string.

_rollBack (line 552)

Roll-back a transaction.

- access: protected
- abstract:

void _rollBack ()

Redefined in descendants as:

- Zend_Db_Adapter_Db2::_rollBack() : Rollback a transaction.
- Zend_Db_Adapter_Oracle::_rollBack() : Roll back a transaction and return to autocommit mode.
- Zend_Db_Adapter_Pdo_Abstract::_rollBack() : Roll-back a transaction.

Documentation generated on Wed, 21 Feb 2007 11:45:21 -0800 by phpDocumentor 1.3.1