Abstract Class Zend_Db_Adapter_Abstract

Description

Class for connecting to SQL databases and performing common operations.

Located in /Db/Adapter/Abstract.php (line 43)


	
			
Direct descendents
Class Description
Abstract class Zend_Db_Adapter_Pdo_Abstract Class for connecting to SQL databases and performing common operations using PDO.
 class Zend_Db_Adapter_Db2
 class Zend_Db_Adapter_Mysqli
 class Zend_Db_Adapter_Sqlsrv
 class Zend_Db_Adapter_Oracle
 class Zend_Test_DbAdapter Testing Database Adapter which acts as a stack for SQL Results
Variable Summary
Method Summary
 Zend_Db_Adapter_Abstract __construct (array|Zend_Config $config)
 void closeConnection ()
 int delete (mixed $table, [mixed $where = ''])
 array describeTable (string $tableName, [string $schemaName = null])
 array fetchAll (string|Zend_Db_Select $sql, [mixed $bind = array()], [mixed $fetchMode = null])
 array fetchAssoc (string|Zend_Db_Select $sql, [mixed $bind = array()])
 array fetchCol (string|Zend_Db_Select $sql, [mixed $bind = array()])
 string fetchOne (string|Zend_Db_Select $sql, [mixed $bind = array()])
 array fetchPairs (string|Zend_Db_Select $sql, [mixed $bind = array()])
 array fetchRow (string|Zend_Db_Select $sql, [mixed $bind = array()], [mixed $fetchMode = null])
 string foldCase (string $key)
 array getConfig ()
 object|resource|null getConnection ()
 int getFetchMode ()
 string getServerVersion ()
 string getStatementClass ()
 int insert (mixed $table,  $bind)
 boolean isConnected ()
 string lastInsertId ([string $tableName = null], [string $primaryKey = null])
 string lastSequenceId (string $sequenceName)
 string limit (mixed $sql, integer $count, [integer $offset = 0])
 array listTables ()
 string nextSequenceId (string $sequenceName)
 Zend_Db_Statement|PDOStatement prepare (string|Zend_Db_Select $sql)
 Zend_Db_Statement_Interface query (mixed $sql, [mixed $bind = array()])
 mixed quote (mixed $value, [mixed $type = null])
 string quoteColumnAs (string|array|Zend_Db_Expr $ident, string $alias, [boolean $auto = false])
 string quoteIdentifier (string|array|Zend_Db_Expr $ident, [boolean $auto = false])
 string quoteInto (string $text, mixed $value, [string $type = null], [integer $count = null])
 string quoteTableAs (string|array|Zend_Db_Expr $ident, [string $alias = null], [boolean $auto = false])
 void setFetchMode (integer $mode)
 bool supportsParameters (string $type)
 int update (mixed $table,  $bind, [mixed $where = ''])
 void _checkRequiredOptions ( $config)
 void _commit ()
 void _connect ()
 string _quote (string $value)
 string _quoteIdentifier (string $value, [boolean $auto = false])
 string _quoteIdentifierAs (string|array|Zend_Db_Expr $ident, [string $alias = null], [boolean $auto = false], [string $as = ' AS '])
 void _rollBack ()
 string _whereExpr (mixed $where)
 array __sleep ()
 void __wakeup ()
Variables
bool $_allowSerialization = true (line 132)

Weither or not that object can get serialized

  • access: protected
bool $_autoQuoteIdentifiers = true (line 109)

Specifies whether the adapter automatically quotes identifiers.

If true, most SQL generated by Zend_Db classes applies identifier quoting automatically. If false, developer must quote identifiers themselves by calling quoteIdentifier().

  • access: protected
bool $_autoReconnectOnUnserialize = false (line 140)

Weither or not the database should be reconnected to that adapter when waking up

  • access: protected
integer $_caseFolding = Zend_Db::CASE_NATURAL (line 98)

Specifies the case of column names retrieved in queries

Options Zend_Db::CASE_NATURAL (default) Zend_Db::CASE_LOWER Zend_Db::CASE_UPPER

  • access: protected
array $_config = array() (line 51)

User-provided configuration

  • access: protected

Redefined in descendants as:
object|resource|null $_connection = null (line 87)

Database connection

  • access: protected
string $_defaultProfilerClass = 'Zend_Db_Profiler' (line 80)

Default class name for the profiler object.

  • access: protected
string $_defaultStmtClass = 'Zend_Db_Statement' (line 73)

Default class name for a DB statement.

  • access: protected

Redefined in descendants as:
integer $_fetchMode = Zend_Db::FETCH_ASSOC (line 58)

Fetch mode

  • access: protected
array $_numericDataTypes = array(
Zend_Db::INT_TYPE => Zend_Db::INT_TYPE,
Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE,
Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE
)
(line 122)

Keys are UPPERCASE SQL datatypes or the constants Zend_Db::INT_TYPE, Zend_Db::BIGINT_TYPE, or Zend_Db::FLOAT_TYPE.

Values are:

  1. = 32-bit integer
  2. = 64-bit integer
  3. = float or decimal

  • var: Associative array of datatypes to values 0, 1, or 2.
  • access: protected

Redefined in descendants as:
Zend_Db_Profiler $_profiler (line 66)

Query profiler object, of type Zend_Db_Profiler or a subclass of that.

  • access: protected
Methods
Constructor __construct (line 163)

Constructor.

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

dbname => (string) The name of the database to user username => (string) Connect to the database as this username. password => (string) Password associated with the username. host => (string) What host to connect to, defaults to localhost

Some options are used on a case-by-case basis by adapters:

port => (string) The port of the database persistent => (boolean) Whether to use a persistent connection or not, defaults to false protocol => (string) The network protocol, defaults to TCPIP caseFolding => (int) style of case-alteration used for identifiers

  • throws: Zend_Db_Adapter_Exception
  • access: public
Zend_Db_Adapter_Abstract __construct (array|Zend_Config $config)
  • array|Zend_Config $config: An array or instance of Zend_Config having configuration data

Redefined in descendants as:
beginTransaction (line 480)

Leave autocommit mode and begin a transaction.

  • access: public
Zend_Db_Adapter_Abstract beginTransaction ()
closeConnection (line 1178)

Force the connection to close.

  • abstract:
  • access: public
void closeConnection ()

Redefined in descendants as:
commit (line 494)

Commit a transaction and return to autocommit mode.

  • access: public
delete (line 619)

Deletes table rows based on a WHERE clause.

  • return: The number of affected rows.
  • access: public
int delete (mixed $table, [mixed $where = ''])
  • mixed $table: The table to update.
  • mixed $where: DELETE WHERE clause(s).
describeTable (line 1157)

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 PRIMARY_POSITION => integer; position of column in primary key

  • abstract:
  • access: public
array describeTable (string $tableName, [string $schemaName = null])
  • string $tableName
  • string $schemaName: OPTIONAL

Redefined in descendants as:
fetchAll (line 701)

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, [mixed $bind = array()], [mixed $fetchMode = null])
  • string|Zend_Db_Select $sql: An SQL SELECT statement.
  • mixed $bind: Data to bind into SELECT placeholders.
  • mixed $fetchMode: Override current fetch mode.
fetchAssoc (line 743)

Fetches all SQL result rows as an associative array.

The first column is the key, the entire row array is the value. You should construct the query to be sure that the first column contains unique values, or else rows with duplicate values in the first column will overwrite previous data.

  • access: public
array fetchAssoc (string|Zend_Db_Select $sql, [mixed $bind = array()])
  • string|Zend_Db_Select $sql: An SQL SELECT statement.
  • mixed $bind: Data to bind into SELECT placeholders.
fetchCol (line 763)

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, [mixed $bind = array()])
  • string|Zend_Db_Select $sql: An SQL SELECT statement.
  • mixed $bind: Data to bind into SELECT placeholders.
fetchOne (line 797)

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

  • access: public
string fetchOne (string|Zend_Db_Select $sql, [mixed $bind = array()])
  • string|Zend_Db_Select $sql: An SQL SELECT statement.
  • mixed $bind: Data to bind into SELECT placeholders.
fetchPairs (line 780)

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
array fetchPairs (string|Zend_Db_Select $sql, [mixed $bind = array()])
  • string|Zend_Db_Select $sql: An SQL SELECT statement.
  • mixed $bind: Data to bind into SELECT placeholders.
fetchRow (line 720)

Fetches the first row of the SQL result.

Uses the current fetchMode for the adapter.

  • access: public
array fetchRow (string|Zend_Db_Select $sql, [mixed $bind = array()], [mixed $fetchMode = null])
  • string|Zend_Db_Select $sql: An SQL SELECT statement.
  • mixed $bind: Data to bind into SELECT placeholders.
  • mixed $fetchMode: Override current fetch mode.
foldCase (line 1073)

Helper method to change the case of the strings used when returning result sets in FETCH_ASSOC and FETCH_BOTH modes.

This is not intended to be used by application code, but the method must be public so the Statement class can invoke it.

  • access: public
string foldCase (string $key)
  • string $key
getConfig (line 313)

Returns the configuration variables in this adapter.

  • access: public
array getConfig ()
getConnection (line 302)

Returns the underlying database connection object or resource.

If not presently connected, this initiates the connection.

  • access: public
object|resource|null getConnection ()
getFetchMode (line 687)

Get the fetch mode.

  • access: public
int getFetchMode ()
getProfiler (line 411)

Returns the profiler for this adapter.

  • access: public
Zend_Db_Profiler getProfiler ()
getQuoteIdentifierSymbol (line 1030)

Returns the symbol the adapter uses for delimited identifiers.

  • access: public
string getQuoteIdentifierSymbol ()

Redefined in descendants as:
getServerVersion (line 1251)

Retrieve server version in PHP style

  • abstract:
  • access: public
string getServerVersion ()

Redefined in descendants as:
getStatementClass (line 421)

Get the default statement class.

  • access: public
string getStatementClass ()
insert (line 524)

Inserts a table row with specified data.

  • return: The number of affected rows.
  • access: public
int insert (mixed $table,  $bind)
  • mixed $table: The table to insert data into.
  • array $bind: Column-value pairs.

Redefined in descendants as:
isConnected (line 1171)

Test if a connection is active

  • abstract:
  • access: public
boolean isConnected ()

Redefined in descendants as:
lastInsertId (line 1202)

Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT column.

As a convention, on RDBMS brands that support sequences (e.g. Oracle, PostgreSQL, DB2), this method forms the name of a sequence from the arguments and returns the last id generated by that sequence. On RDBMS brands that support IDENTITY/AUTOINCREMENT columns, this method returns the last value generated for such a column, and the table name argument is disregarded.

  • abstract:
  • access: public
string lastInsertId ([string $tableName = null], [string $primaryKey = null])
  • string $tableName: OPTIONAL Name of table.
  • string $primaryKey: OPTIONAL Name of primary key column.

Redefined in descendants as:
lastSequenceId (line 1043)

Return the most recent value from the specified sequence in the database.

This is supported only on RDBMS brands that support sequences (e.g. Oracle, PostgreSQL, DB2). Other RDBMS brands return null.

  • access: public
string lastSequenceId (string $sequenceName)
  • string $sequenceName

Redefined in descendants as:
limit (line 1236)

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

  • abstract:
  • access: public
string limit (mixed $sql, integer $count, [integer $offset = 0])
  • mixed $sql
  • integer $count
  • integer $offset

Redefined in descendants as:
listTables (line 1128)

Returns a list of the tables in the database.

  • abstract:
  • access: public
array listTables ()

Redefined in descendants as:
nextSequenceId (line 1056)

Generate a new value from the specified sequence in the database, and return it.

This is supported only on RDBMS brands that support sequences (e.g. Oracle, PostgreSQL, DB2). Other RDBMS brands return null.

  • access: public
string nextSequenceId (string $sequenceName)
  • string $sequenceName

Redefined in descendants as:
prepare (line 1186)

Prepare a statement and return a PDOStatement-like object.

  • abstract:
  • access: public
Zend_Db_Statement|PDOStatement prepare (string|Zend_Db_Select $sql)

Redefined in descendants as:
query (line 445)

Prepares and executes an SQL statement with bound data.

  • access: public
Zend_Db_Statement_Interface query (mixed $sql, [mixed $bind = array()])
  • mixed $sql: The SQL statement with placeholders. May be a string or Zend_Db_Select.
  • mixed $bind: An array of data to bind to the placeholders.

Redefined in descendants as:
quote (line 830)

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 $type = null])
  • mixed $value: The value to quote.
  • mixed $type: OPTIONAL the SQL datatype name, or constant, or null.
quoteColumnAs (line 949)

Quote a column identifier and alias.

  • return: The quoted identifier and alias.
  • access: public
string quoteColumnAs (string|array|Zend_Db_Expr $ident, string $alias, [boolean $auto = false])
  • string|array|Zend_Db_Expr $ident: The identifier or expression.
  • string $alias: An alias for the column.
  • boolean $auto: If true, heed the AUTO_QUOTE_IDENTIFIERS config option.
quoteIdentifier (line 936)

Quotes an identifier.

Accepts a string representing a qualified indentifier. For Example:

  1.  $adapter->quoteIdentifier('myschema.mytable')
Returns: "myschema"."mytable"

Or, an array of one or more identifiers that may form a qualified identifier:

  1.  $adapter->quoteIdentifier(array('myschema','my.table'))
Returns: "myschema"."my.table"

The actual quote character surrounding the identifiers may vary depending on the adapter.

  • return: The quoted identifier.
  • access: public
string quoteIdentifier (string|array|Zend_Db_Expr $ident, [boolean $auto = false])
  • string|array|Zend_Db_Expr $ident: The identifier.
  • boolean $auto: If true, heed the AUTO_QUOTE_IDENTIFIERS config option.
quoteInto (line 899)

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);
  4.  // $safe = "WHERE date < '2005-01-02'"

  • return: An SQL-safe quoted value placed into the original text.
  • access: public
string quoteInto (string $text, mixed $value, [string $type = null], [integer $count = null])
  • string $text: The text with a placeholder.
  • mixed $value: The value to quote.
  • string $type: OPTIONAL SQL datatype
  • integer $count: OPTIONAL count of placeholders to replace
quoteTableAs (line 962)

Quote a table identifier and alias.

  • return: The quoted identifier and alias.
  • access: public
string quoteTableAs (string|array|Zend_Db_Expr $ident, [string $alias = null], [boolean $auto = false])
  • string|array|Zend_Db_Expr $ident: The identifier or expression.
  • string $alias: An alias for the table.
  • boolean $auto: If true, heed the AUTO_QUOTE_IDENTIFIERS config option.

Redefined in descendants as:
rollBack (line 508)

Roll back a transaction and return to autocommit mode.

  • access: public
select (line 677)

Creates and returns a new Zend_Db_Select object for this adapter.

  • access: public
Zend_Db_Select select ()
setFetchMode (line 1226)

Set the fetch mode.

  • abstract:
  • throws: Zend_Db_Adapter_Exception
  • access: public
void setFetchMode (integer $mode)
  • integer $mode

Redefined in descendants as:
setProfiler (line 346)

Set the adapter's profiler object.

The argument may be a boolean, an associative array, an instance of Zend_Db_Profiler, or an instance of Zend_Config.

A boolean argument sets the profiler to enabled if true, or disabled if false. The profiler class is the adapter's default profiler class, Zend_Db_Profiler.

An instance of Zend_Db_Profiler sets the adapter's instance to that object. The profiler is enabled and disabled separately.

An associative array argument may contain any of the keys 'enabled', 'class', and 'instance'. The 'enabled' and 'instance' keys correspond to the boolean and object types documented above. The 'class' key is used to name a class to use for a custom profiler. The class must be Zend_Db_Profiler or a subclass. The class is instantiated with no constructor arguments. The 'class' option is ignored when the 'instance' option is supplied.

An object of type Zend_Config may contain the properties 'enabled', 'class', and 'instance', just as if an associative array had been passed instead.

  • return: Provides a fluent interface
  • throws: Zend_Db_Profiler_Exception if the object instance or class specified is not Zend_Db_Profiler or an extension of that class.
  • access: public
Zend_Db_Adapter_Abstract setProfiler (Zend_Db_Profiler|Zend_Config|array|boolean $profiler)
setStatementClass (line 431)

Set the default statement class.

  • return: Fluent interface
  • access: public
Zend_Db_Adapter_Abstract setStatementClass ( $class)
  • $class
supportsParameters (line 1244)

Check if the adapter supports real SQL parameters.

  • abstract:
  • access: public
bool supportsParameters (string $type)
  • string $type: 'positional' or 'named'

Redefined in descendants as:
update (line 559)

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

  • return: The number of affected rows.
  • access: public
int update (mixed $table,  $bind, [mixed $where = ''])
  • mixed $table: The table to update.
  • array $bind: Column-value pairs.
  • mixed $where: UPDATE WHERE clause(s).
_beginTransaction (line 1207)

Begin a transaction.

  • abstract:
  • access: protected
void _beginTransaction ()

Redefined in descendants as:
_checkRequiredOptions (line 270)

Check for config options that are mandatory.

Throw exceptions if any are missing.

  • throws: Zend_Db_Adapter_Exception
  • access: protected
void _checkRequiredOptions ( $config)
  • array $config

Redefined in descendants as:
_commit (line 1212)

Commit a transaction.

  • abstract:
  • access: protected
void _commit ()

Redefined in descendants as:
_connect (line 1164)

Creates a connection to the database.

  • abstract:
  • access: protected
void _connect ()

Redefined in descendants as:
_quote (line 810)

Quote a raw string.

  • return: Quoted string
  • access: protected
string _quote (string $value)
  • string $value: Raw string

Redefined in descendants as:
_quoteIdentifier (line 1016)

Quote an identifier.

  • return: The quoted identifier and alias.
  • access: protected
string _quoteIdentifier (string $value, [boolean $auto = false])
  • string $value: The identifier or expression.
  • boolean $auto: If true, heed the AUTO_QUOTE_IDENTIFIERS config option.
_quoteIdentifierAs (line 976)

Quote an identifier and an optional alias.

  • return: The quoted identifier and alias.
  • access: protected
string _quoteIdentifierAs (string|array|Zend_Db_Expr $ident, [string $alias = null], [boolean $auto = false], [string $as = ' AS '])
  • string|array|Zend_Db_Expr $ident: The identifier or expression.
  • string $alias: An optional alias.
  • boolean $auto: If true, heed the AUTO_QUOTE_IDENTIFIERS config option.
  • string $as: The string to add between the identifier/expression and the alias.
_rollBack (line 1217)

Roll-back a transaction.

  • abstract:
  • access: protected
void _rollBack ()

Redefined in descendants as:
_whereExpr (line 645)

Convert an array, string, or Zend_Db_Expr object into a string to put in a WHERE clause.

  • access: protected
string _whereExpr (mixed $where)
  • mixed $where
__sleep (line 1096)

called when object is getting serialized This disconnects the DB object that cant be serialized

  • throws: Zend_Db_Adapter_Exception
  • access: public
array __sleep ()
__wakeup (line 1112)

called when object is getting unserialized

  • access: public
void __wakeup ()

Documentation generated on Mon, 21 Jun 2010 15:05:24 -0400 by phpDocumentor 1.4.3