Public Member Functions | |
__construct ($config) | |
getConnection () | |
getConfig () | |
setProfiler ($profiler) | |
getProfiler () | |
getStatementClass () | |
setStatementClass ($class) | |
query ($sql, $bind=array()) | |
beginTransaction () | |
commit () | |
rollBack () | |
insert ($table, array $bind) | |
update ($table, array $bind, $where= '') | |
delete ($table, $where= '') | |
select () | |
getFetchMode () | |
fetchAll ($sql, $bind=array(), $fetchMode=null) | |
fetchRow ($sql, $bind=array(), $fetchMode=null) | |
fetchAssoc ($sql, $bind=array()) | |
fetchCol ($sql, $bind=array()) | |
fetchPairs ($sql, $bind=array()) | |
fetchOne ($sql, $bind=array()) | |
quote ($value, $type=null) | |
quoteInto ($text, $value, $type=null, $count=null) | |
quoteIdentifier ($ident, $auto=false) | |
quoteColumnAs ($ident, $alias, $auto=false) | |
quoteTableAs ($ident, $alias=null, $auto=false) | |
getQuoteIdentifierSymbol () | |
lastSequenceId ($sequenceName) | |
nextSequenceId ($sequenceName) | |
foldCase ($key) | |
__sleep () | |
__wakeup () | |
listTables () | |
describeTable ($tableName, $schemaName=null) | |
isConnected () | |
closeConnection () | |
prepare ($sql) | |
lastInsertId ($tableName=null, $primaryKey=null) | |
setFetchMode ($mode) | |
limit ($sql, $count, $offset=0) | |
supportsParameters ($type) | |
getServerVersion () | |
Protected Member Functions | |
_checkRequiredOptions (array $config) | |
_whereExpr ($where) | |
_quote ($value) | |
_quoteIdentifierAs ($ident, $alias=null, $auto=false, $as= 'AS ') | |
_quoteIdentifier ($value, $auto=false) | |
_connect () | |
_beginTransaction () | |
_commit () | |
_rollBack () | |
Protected Attributes | |
$_config = array() | |
$_fetchMode = Zend_Db::FETCH_ASSOC | |
$_profiler | |
$_defaultStmtClass = 'Zend_Db_Statement' | |
$_defaultProfilerClass = 'Zend_Db_Profiler' | |
$_connection = null | |
$_caseFolding = Zend_Db::CASE_NATURAL | |
$_autoQuoteIdentifiers = true | |
$_numericDataTypes | |
$_allowSerialization = true | |
$_autoReconnectOnUnserialize = false |
Definition at line 43 of file Abstract.php.
__construct | ( | $ | config ) |
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
array | Zend_Config | $config | An array or instance of Zend_Config having configuration data |
Zend_Db_Adapter_Exception |
Definition at line 163 of file Abstract.php.
__sleep | ( | ) |
called when object is getting serialized This disconnects the DB object that cant be serialized
Zend_Db_Adapter_Exception |
Definition at line 1096 of file Abstract.php.
__wakeup | ( | ) |
called when object is getting unserialized
Definition at line 1112 of file Abstract.php.
_beginTransaction | ( | ) | [abstract, protected] |
Begin a transaction.
Reimplemented in Zend_Db_Adapter_Db2, Zend_Db_Adapter_Mysqli, Zend_Db_Adapter_Oracle, Zend_Db_Adapter_Pdo_Abstract, Zend_Db_Adapter_Pdo_Mssql, Zend_Db_Adapter_Sqlsrv, and ZendX_Db_Adapter_Firebird.
_checkRequiredOptions | ( | array $ | config ) | [protected] |
Check for config options that are mandatory. Throw exceptions if any are missing.
array | $config |
Zend_Db_Adapter_Exception |
Reimplemented in Zend_Db_Adapter_Pdo_Ibm, Zend_Db_Adapter_Pdo_Sqlite, and Zend_Db_Adapter_Sqlsrv.
Definition at line 270 of file Abstract.php.
_commit | ( | ) | [abstract, protected] |
Commit a transaction.
Reimplemented in Zend_Db_Adapter_Db2, Zend_Db_Adapter_Mysqli, Zend_Db_Adapter_Oracle, Zend_Db_Adapter_Pdo_Abstract, Zend_Db_Adapter_Pdo_Mssql, Zend_Db_Adapter_Sqlsrv, and ZendX_Db_Adapter_Firebird.
_connect | ( | ) | [abstract, protected] |
Creates a connection to the database.
Reimplemented in Zend_Db_Adapter_Db2, Zend_Db_Adapter_Mysqli, Zend_Db_Adapter_Oracle, Zend_Db_Adapter_Pdo_Abstract, Zend_Db_Adapter_Pdo_Ibm, Zend_Db_Adapter_Pdo_Mssql, Zend_Db_Adapter_Pdo_Mysql, Zend_Db_Adapter_Pdo_Pgsql, Zend_Db_Adapter_Pdo_Sqlite, Zend_Db_Adapter_Sqlsrv, and ZendX_Db_Adapter_Firebird.
_quote | ( | $ | value ) | [protected] |
Quote a raw string.
string | $value | Raw string |
Reimplemented in Zend_Db_Adapter_Db2, Zend_Db_Adapter_Mysqli, Zend_Db_Adapter_Oracle, Zend_Db_Adapter_Pdo_Abstract, Zend_Db_Adapter_Pdo_Oci, Zend_Db_Adapter_Sqlsrv, and ZendX_Db_Adapter_Firebird.
Definition at line 810 of file Abstract.php.
_quoteIdentifier | ( | $ | value, |
$ | auto = false |
||
) | [protected] |
Quote an identifier.
string | $value | The identifier or expression. |
boolean | $auto | If true, heed the AUTO_QUOTE_IDENTIFIERS config option. |
Definition at line 1016 of file Abstract.php.
_quoteIdentifierAs | ( | $ | ident, |
$ | alias = null , |
||
$ | auto = false , |
||
$ | as = ' AS ' |
||
) | [protected] |
Quote an identifier and an optional alias.
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. |
Definition at line 976 of file Abstract.php.
_rollBack | ( | ) | [abstract, protected] |
Roll-back a transaction.
Reimplemented in Zend_Db_Adapter_Db2, Zend_Db_Adapter_Mysqli, Zend_Db_Adapter_Oracle, Zend_Db_Adapter_Pdo_Abstract, Zend_Db_Adapter_Pdo_Mssql, Zend_Db_Adapter_Sqlsrv, and ZendX_Db_Adapter_Firebird.
_whereExpr | ( | $ | where ) | [protected] |
Convert an array, string, or Zend_Db_Expr object into a string to put in a WHERE clause.
mixed | $where |
Definition at line 645 of file Abstract.php.
beginTransaction | ( | ) |
Leave autocommit mode and begin a transaction.
Definition at line 480 of file Abstract.php.
closeConnection | ( | ) | [abstract] |
Force the connection to close.
Reimplemented in Zend_Db_Adapter_Db2, Zend_Db_Adapter_Mysqli, Zend_Db_Adapter_Oracle, Zend_Db_Adapter_Pdo_Abstract, Zend_Db_Adapter_Sqlsrv, and ZendX_Db_Adapter_Firebird.
commit | ( | ) |
Commit a transaction and return to autocommit mode.
Definition at line 494 of file Abstract.php.
delete | ( | $ | table, |
$ | where = '' |
||
) |
Deletes table rows based on a WHERE clause.
mixed | $table | The table to update. |
mixed | $where | DELETE WHERE clause(s). |
Build the DELETE statement
Execute the statement and return the number of affected rows
Definition at line 619 of file Abstract.php.
describeTable | ( | $ | tableName, |
$ | schemaName = null |
||
) | [abstract] |
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
string | $tableName | |
string | $schemaName | OPTIONAL |
Reimplemented in Zend_Db_Adapter_Db2, Zend_Db_Adapter_Mysqli, Zend_Db_Adapter_Oracle, Zend_Db_Adapter_Pdo_Ibm, Zend_Db_Adapter_Pdo_Mssql, Zend_Db_Adapter_Pdo_Mysql, Zend_Db_Adapter_Pdo_Oci, Zend_Db_Adapter_Pdo_Pgsql, Zend_Db_Adapter_Pdo_Sqlite, Zend_Db_Adapter_Sqlsrv, and ZendX_Db_Adapter_Firebird.
fetchAll | ( | $ | sql, |
$ | bind = array() , |
||
$ | fetchMode = null |
||
) |
Fetches all SQL result rows as a sequential array. Uses the current fetchMode for the adapter.
string | Zend_Db_Select | $sql | An SQL SELECT statement. |
mixed | $bind | Data to bind into SELECT placeholders. |
mixed | $fetchMode | Override current fetch mode. |
Definition at line 701 of file Abstract.php.
fetchAssoc | ( | $ | sql, |
$ | bind = array() |
||
) |
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.
string | Zend_Db_Select | $sql | An SQL SELECT statement. |
mixed | $bind | Data to bind into SELECT placeholders. |
Definition at line 743 of file Abstract.php.
fetchCol | ( | $ | sql, |
$ | bind = array() |
||
) |
Fetches the first column of all SQL result rows as an array.
The first column in each row is used as the array key.
string | Zend_Db_Select | $sql | An SQL SELECT statement. |
mixed | $bind | Data to bind into SELECT placeholders. |
Definition at line 763 of file Abstract.php.
fetchOne | ( | $ | sql, |
$ | bind = array() |
||
) |
Fetches the first column of the first row of the SQL result.
string | Zend_Db_Select | $sql | An SQL SELECT statement. |
mixed | $bind | Data to bind into SELECT placeholders. |
Definition at line 797 of file Abstract.php.
fetchPairs | ( | $ | sql, |
$ | bind = array() |
||
) |
Fetches all SQL result rows as an array of key-value pairs.
The first column is the key, the second column is the value.
string | Zend_Db_Select | $sql | An SQL SELECT statement. |
mixed | $bind | Data to bind into SELECT placeholders. |
Definition at line 780 of file Abstract.php.
fetchRow | ( | $ | sql, |
$ | bind = array() , |
||
$ | fetchMode = null |
||
) |
Fetches the first row of the SQL result. Uses the current fetchMode for the adapter.
string | Zend_Db_Select | $sql | An SQL SELECT statement. |
mixed | $bind | Data to bind into SELECT placeholders. |
mixed | $fetchMode | Override current fetch mode. |
Definition at line 720 of file Abstract.php.
foldCase | ( | $ | key ) |
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.
string | $key |
Definition at line 1073 of file Abstract.php.
getConfig | ( | ) |
Returns the configuration variables in this adapter.
Definition at line 313 of file Abstract.php.
getConnection | ( | ) |
Returns the underlying database connection object or resource. If not presently connected, this initiates the connection.
Definition at line 302 of file Abstract.php.
getFetchMode | ( | ) |
getProfiler | ( | ) |
Returns the profiler for this adapter.
Definition at line 411 of file Abstract.php.
getQuoteIdentifierSymbol | ( | ) |
Returns the symbol the adapter uses for delimited identifiers.
Reimplemented in Zend_Db_Adapter_Db2, Zend_Db_Adapter_Mysqli, and Zend_Db_Adapter_Pdo_Mysql.
Definition at line 1030 of file Abstract.php.
getServerVersion | ( | ) | [abstract] |
Retrieve server version in PHP style
Reimplemented in Zend_Db_Adapter_Db2, Zend_Db_Adapter_Mysqli, Zend_Db_Adapter_Oracle, Zend_Db_Adapter_Pdo_Abstract, Zend_Db_Adapter_Pdo_Ibm, Zend_Db_Adapter_Pdo_Mssql, Zend_Db_Adapter_Sqlsrv, and ZendX_Db_Adapter_Firebird.
getStatementClass | ( | ) |
insert | ( | $ | table, |
array $ | bind | ||
) |
Inserts a table row with specified data.
mixed | $table | The table to insert data into. |
array | $bind | Column-value pairs. |
Reimplemented in Zend_Db_Adapter_Oracle, Zend_Db_Adapter_Pdo_Ibm, and Zend_Db_Adapter_Sqlsrv.
Definition at line 524 of file Abstract.php.
isConnected | ( | ) | [abstract] |
Test if a connection is active
Reimplemented in Zend_Db_Adapter_Db2, Zend_Db_Adapter_Mysqli, Zend_Db_Adapter_Oracle, Zend_Db_Adapter_Pdo_Abstract, Zend_Db_Adapter_Sqlsrv, and ZendX_Db_Adapter_Firebird.
lastInsertId | ( | $ | tableName = null , |
$ | primaryKey = null |
||
) | [abstract] |
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.
string | $tableName | OPTIONAL Name of table. |
string | $primaryKey | OPTIONAL Name of primary key column. |
Reimplemented in Zend_Db_Adapter_Mysqli, Zend_Db_Adapter_Oracle, Zend_Db_Adapter_Pdo_Abstract, Zend_Db_Adapter_Pdo_Ibm, Zend_Db_Adapter_Pdo_Mssql, Zend_Db_Adapter_Pdo_Oci, Zend_Db_Adapter_Pdo_Pgsql, Zend_Db_Adapter_Sqlsrv, and ZendX_Db_Adapter_Firebird.
lastSequenceId | ( | $ | sequenceName ) |
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.
string | $sequenceName |
Reimplemented in Zend_Db_Adapter_Db2, Zend_Db_Adapter_Oracle, Zend_Db_Adapter_Pdo_Ibm, Zend_Db_Adapter_Pdo_Oci, Zend_Db_Adapter_Pdo_Pgsql, and ZendX_Db_Adapter_Firebird.
Definition at line 1043 of file Abstract.php.
limit | ( | $ | sql, |
$ | count, | ||
$ | offset = 0 |
||
) | [abstract] |
Adds an adapter-specific LIMIT clause to the SELECT statement.
mixed | $sql | |
integer | $count | |
integer | $offset |
Reimplemented in Zend_Db_Adapter_Db2, Zend_Db_Adapter_Mysqli, Zend_Db_Adapter_Oracle, Zend_Db_Adapter_Pdo_Ibm, Zend_Db_Adapter_Pdo_Mssql, Zend_Db_Adapter_Pdo_Mysql, Zend_Db_Adapter_Pdo_Oci, Zend_Db_Adapter_Pdo_Pgsql, Zend_Db_Adapter_Pdo_Sqlite, Zend_Db_Adapter_Sqlsrv, and ZendX_Db_Adapter_Firebird.
listTables | ( | ) | [abstract] |
Abstract Methods Returns a list of the tables in the database.
Reimplemented in Zend_Db_Adapter_Mysqli, Zend_Db_Adapter_Oracle, Zend_Db_Adapter_Pdo_Ibm, Zend_Db_Adapter_Pdo_Mssql, Zend_Db_Adapter_Pdo_Mysql, Zend_Db_Adapter_Pdo_Oci, Zend_Db_Adapter_Pdo_Pgsql, Zend_Db_Adapter_Pdo_Sqlite, Zend_Db_Adapter_Sqlsrv, and ZendX_Db_Adapter_Firebird.
nextSequenceId | ( | $ | sequenceName ) |
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.
string | $sequenceName |
Reimplemented in Zend_Db_Adapter_Db2, Zend_Db_Adapter_Oracle, Zend_Db_Adapter_Pdo_Ibm, Zend_Db_Adapter_Pdo_Oci, Zend_Db_Adapter_Pdo_Pgsql, and ZendX_Db_Adapter_Firebird.
Definition at line 1056 of file Abstract.php.
prepare | ( | $ | sql ) | [abstract] |
Prepare a statement and return a PDOStatement-like object.
string | Zend_Db_Select | $sql | SQL query |
Reimplemented in Zend_Db_Adapter_Db2, Zend_Db_Adapter_Mysqli, Zend_Db_Adapter_Oracle, Zend_Db_Adapter_Pdo_Abstract, Zend_Db_Adapter_Pdo_Ibm, Zend_Db_Adapter_Sqlsrv, and ZendX_Db_Adapter_Firebird.
query | ( | $ | sql, |
$ | bind = array() |
||
) |
Prepares and executes an SQL statement with bound data.
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. |
Reimplemented in Zend_Db_Adapter_Pdo_Abstract.
Definition at line 445 of file Abstract.php.
quote | ( | $ | value, |
$ | type = null |
||
) |
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.
mixed | $value | The value to quote. |
mixed | $type | OPTIONAL the SQL datatype name, or constant, or null. |
Definition at line 830 of file Abstract.php.
quoteColumnAs | ( | $ | ident, |
$ | alias, | ||
$ | auto = false |
||
) |
Quote a column identifier and alias.
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. |
Definition at line 949 of file Abstract.php.
quoteIdentifier | ( | $ | ident, |
$ | auto = false |
||
) |
Quotes an identifier.
Accepts a string representing a qualified indentifier. For Example: $adapter->quoteIdentifier('myschema.mytable')
Returns: "myschema"."mytable"
Or, an array of one or more identifiers that may form a qualified identifier: $adapter->quoteIdentifier(array('myschema','my.table'))
Returns: "myschema"."my.table"
The actual quote character surrounding the identifiers may vary depending on the adapter.
string | array | Zend_Db_Expr | $ident | The identifier. |
boolean | $auto | If true, heed the AUTO_QUOTE_IDENTIFIERS config option. |
Definition at line 936 of file Abstract.php.
quoteInto | ( | $ | text, |
$ | value, | ||
$ | type = null , |
||
$ | count = null |
||
) |
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:
$text = "WHERE date < ?"; $date = "2005-01-02"; $safe = $sql->quoteInto($text, $date); // $safe = "WHERE date < '2005-01-02'"
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 |
Definition at line 899 of file Abstract.php.
quoteTableAs | ( | $ | ident, |
$ | alias = null , |
||
$ | auto = false |
||
) |
Quote a table identifier and alias.
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. |
Reimplemented in Zend_Db_Adapter_Oracle, Zend_Db_Adapter_Pdo_Oci, and ZendX_Db_Adapter_Firebird.
Definition at line 962 of file Abstract.php.
rollBack | ( | ) |
Roll back a transaction and return to autocommit mode.
Definition at line 508 of file Abstract.php.
select | ( | ) |
Creates and returns a new Zend_Db_Select object for this adapter.
Definition at line 677 of file Abstract.php.
setFetchMode | ( | $ | mode ) | [abstract] |
Set the fetch mode.
integer | $mode |
Zend_Db_Adapter_Exception |
Reimplemented in Zend_Db_Adapter_Db2, Zend_Db_Adapter_Mysqli, Zend_Db_Adapter_Oracle, Zend_Db_Adapter_Pdo_Abstract, Zend_Db_Adapter_Sqlsrv, and ZendX_Db_Adapter_Firebird.
setProfiler | ( | $ | profiler ) |
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.
Zend_Db_Profiler | Zend_Config | array | boolean | $profiler |
Zend_Db_Profiler_Exception | if the object instance or class specified is not Zend_Db_Profiler or an extension of that class. |
Definition at line 346 of file Abstract.php.
setStatementClass | ( | $ | class ) |
Set the default statement class.
Definition at line 431 of file Abstract.php.
supportsParameters | ( | $ | type ) | [abstract] |
Check if the adapter supports real SQL parameters.
string | $type | 'positional' or 'named' |
Reimplemented in Zend_Db_Adapter_Db2, Zend_Db_Adapter_Mysqli, Zend_Db_Adapter_Oracle, Zend_Db_Adapter_Pdo_Abstract, Zend_Db_Adapter_Sqlsrv, and ZendX_Db_Adapter_Firebird.
update | ( | $ | table, |
array $ | bind, | ||
$ | where = '' |
||
) |
Updates table rows with specified data based on a WHERE clause.
mixed | $table | The table to update. |
array | $bind | Column-value pairs. |
mixed | $where | UPDATE WHERE clause(s). |
Build "col = ?" pairs for the statement, except for Zend_Db_Expr which is treated literally.
Build the UPDATE statement
Execute the statement and return the number of affected rows
Definition at line 559 of file Abstract.php.
$_numericDataTypes [protected] |
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 )
Definition at line 122 of file Abstract.php.