Db/Adapter/Abstract.php
- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Db
- Subpackage
- Adapter
- Version
- $Id$
\Zend_Db_Adapter_Abstract
- Children
- \Zend_Db_Adapter_Oracle
- \Zend_Db_Adapter_Mysqli
- \Zend_Db_Adapter_Pdo_Abstract
- \Zend_Db_Adapter_Sqlsrv
- \Zend_Db_Adapter_Db2
- \Zend_Test_DbAdapter
- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Properties

bool $_allowSerialization = truetrueDetails- Type
- bool

bool $_autoQuoteIdentifiers = truetrueDetails- Type
- bool

bool $_autoReconnectOnUnserialize = falsefalseDetails- Type
- bool

integer $_caseFolding = \Zend_Db::CASE_NATURAL\Zend_Db::CASE_NATURALDetails- Type
- integer

object|resource|null $_connection = nullnullDetails- Type
- object | resource | null

string $_defaultProfilerClass = 'Zend_Db_Profiler''Zend_Db_Profiler'Details- Type
- string

string $_defaultStmtClass = 'Zend_Db_Statement''Zend_Db_Statement'Details- Type
- string

integer $_fetchMode = \Zend_Db::FETCH_ASSOC\Zend_Db::FETCH_ASSOCDetails- Type
- integer

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)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)Details- Type
- array
Methods

__construct(array | \Zend_Config $config) : voidConstructor.
| Name | Type | Description |
|---|---|---|
| $config | array | \Zend_Config | An array or instance of Zend_Config having configuration data |
| Exception | Description |
|---|---|
| \Zend_Db_Adapter_Exception |

__sleep() : arraycalled when object is getting serialized This disconnects the DB object that cant be serialized
| Type | Description |
|---|---|
| array |
| Exception | Description |
|---|---|
| \Zend_Db_Adapter_Exception |

_checkRequiredOptions(array $config) : voidCheck for config options that are mandatory.
| Name | Type | Description |
|---|---|---|
| $config | array |
| Exception | Description |
|---|---|
| \Zend_Db_Adapter_Exception |

_quote(string $value) : stringQuote a raw string.
| Name | Type | Description |
|---|---|---|
| $value | string | Raw string |
| Type | Description |
|---|---|
| string | Quoted string |

_quoteIdentifier(string $value, boolean $auto = false) : stringQuote an identifier.
| Name | Type | Description |
|---|---|---|
| $value | string | The identifier or expression. |
| $auto | boolean | If true, heed the AUTO_QUOTE_IDENTIFIERS config option. |
| Type | Description |
|---|---|
| string | The quoted identifier and alias. |

_quoteIdentifierAs(string | array | \Zend_Db_Expr $ident, string $alias = null, boolean $auto = false, string $as = ' AS ') : stringQuote an identifier and an optional alias.
| Name | Type | Description |
|---|---|---|
| $ident | string | array | \Zend_Db_Expr | The identifier or expression. |
| $alias | string | An optional alias. |
| $auto | boolean | If true, heed the AUTO_QUOTE_IDENTIFIERS config option. |
| $as | string | The string to add between the identifier/expression and the alias. |
| Type | Description |
|---|---|
| string | The quoted identifier and alias. |

_whereExpr(mixed $where) : stringConvert an array, string, or Zend_Db_Expr object into a string to put in a WHERE clause.
| Name | Type | Description |
|---|---|---|
| $where | mixed |
| Type | Description |
|---|---|
| string |

beginTransaction() : \Zend_Db_Adapter_AbstractLeave autocommit mode and begin a transaction.
| Type | Description |
|---|---|
| \Zend_Db_Adapter_Abstract |

commit() : \Zend_Db_Adapter_AbstractCommit a transaction and return to autocommit mode.
| Type | Description |
|---|---|
| \Zend_Db_Adapter_Abstract |

delete(mixed $table, mixed $where = '') : intDeletes table rows based on a WHERE clause.
| Name | Type | Description |
|---|---|---|
| $table | mixed | The table to update. |
| $where | mixed | DELETE WHERE clause(s). |
| Type | Description |
|---|---|
| int | The number of affected rows. |

describeTable(string $tableName, string $schemaName = null) : arrayReturns the column descriptions for a table.
| Name | Type | Description |
|---|---|---|
| $tableName | string | |
| $schemaName | string | OPTIONAL |
| Type | Description |
|---|---|
| array |

fetchAll(string | \Zend_Db_Select $sql, mixed $bind = array(), mixed $fetchMode = null) : arrayFetches all SQL result rows as a sequential array.
| Name | Type | Description |
|---|---|---|
| $sql | string | \Zend_Db_Select | An SQL SELECT statement. |
| $bind | mixed | Data to bind into SELECT placeholders. |
| $fetchMode | mixed | Override current fetch mode. |
| Type | Description |
|---|---|
| array |

fetchAssoc(string | \Zend_Db_Select $sql, mixed $bind = array()) : arrayFetches all SQL result rows as an associative array.
| Name | Type | Description |
|---|---|---|
| $sql | string | \Zend_Db_Select | An SQL SELECT statement. |
| $bind | mixed | Data to bind into SELECT placeholders. |
| Type | Description |
|---|---|
| array |

fetchCol(string | \Zend_Db_Select $sql, mixed $bind = array()) : arrayFetches the first column of all SQL result rows as an array.
| Name | Type | Description |
|---|---|---|
| $sql | string | \Zend_Db_Select | An SQL SELECT statement. |
| $bind | mixed | Data to bind into SELECT placeholders. |
| Type | Description |
|---|---|
| array |

fetchOne(string | \Zend_Db_Select $sql, mixed $bind = array()) : stringFetches the first column of the first row of the SQL result.
| Name | Type | Description |
|---|---|---|
| $sql | string | \Zend_Db_Select | An SQL SELECT statement. |
| $bind | mixed | Data to bind into SELECT placeholders. |
| Type | Description |
|---|---|
| string |

fetchPairs(string | \Zend_Db_Select $sql, mixed $bind = array()) : arrayFetches all SQL result rows as an array of key-value pairs.
| Name | Type | Description |
|---|---|---|
| $sql | string | \Zend_Db_Select | An SQL SELECT statement. |
| $bind | mixed | Data to bind into SELECT placeholders. |
| Type | Description |
|---|---|
| array |

fetchRow(string | \Zend_Db_Select $sql, mixed $bind = array(), mixed $fetchMode = null) : mixedFetches the first row of the SQL result.
| Name | Type | Description |
|---|---|---|
| $sql | string | \Zend_Db_Select | An SQL SELECT statement. |
| $bind | mixed | Data to bind into SELECT placeholders. |
| $fetchMode | mixed | Override current fetch mode. |
| Type | Description |
|---|---|
| mixed | Array, object, or scalar depending on fetch mode. |

foldCase(string $key) : stringHelper method to change the case of the strings used when returning result sets in FETCH_ASSOC and FETCH_BOTH modes.
| Name | Type | Description |
|---|---|---|
| $key | string |
| Type | Description |
|---|---|
| string |

getConnection() : object | resource | nullReturns the underlying database connection object or resource.
| Type | Description |
|---|---|
| object | resource | null |

getProfiler() : \Zend_Db_ProfilerReturns the profiler for this adapter.
| Type | Description |
|---|---|
| \Zend_Db_Profiler |

getQuoteIdentifierSymbol() : stringReturns the symbol the adapter uses for delimited identifiers.
| Type | Description |
|---|---|
| string |

insert(mixed $table, array $bind) : intInserts a table row with specified data.
| Name | Type | Description |
|---|---|---|
| $table | mixed | The table to insert data into. |
| $bind | array | Column-value pairs. |
| Type | Description |
|---|---|
| int | The number of affected rows. |
| Exception | Description |
|---|---|
| \Zend_Db_Adapter_Exception |

lastInsertId(string $tableName = null, string $primaryKey = null) : stringGets the last ID generated automatically by an IDENTITY/AUTOINCREMENT column.
| Name | Type | Description |
|---|---|---|
| $tableName | string | OPTIONAL Name of table. |
| $primaryKey | string | OPTIONAL Name of primary key column. |
| Type | Description |
|---|---|
| string |

lastSequenceId(string $sequenceName) : stringReturn the most recent value from the specified sequence in the database.
| Name | Type | Description |
|---|---|---|
| $sequenceName | string |
| Type | Description |
|---|---|
| string |

limit(mixed $sql, integer $count, integer $offset = 0) : stringAdds an adapter-specific LIMIT clause to the SELECT statement.
| Name | Type | Description |
|---|---|---|
| $sql | mixed | |
| $count | integer | |
| $offset | integer |
| Type | Description |
|---|---|
| string |

listTables() : arrayReturns a list of the tables in the database.
| Type | Description |
|---|---|
| array |

nextSequenceId(string $sequenceName) : stringGenerate a new value from the specified sequence in the database, and return it.
| Name | Type | Description |
|---|---|---|
| $sequenceName | string |
| Type | Description |
|---|---|
| string |

prepare(string | \Zend_Db_Select $sql) : \Zend_Db_Statement | \PDOStatementPrepare a statement and return a PDOStatement-like object.
| Name | Type | Description |
|---|---|---|
| $sql | string | \Zend_Db_Select | SQL query |
| Type | Description |
|---|---|
| \Zend_Db_Statement | \PDOStatement |

query(mixed $sql, mixed $bind = array()) : \Zend_Db_Statement_InterfacePrepares and executes an SQL statement with bound data.
| Name | Type | Description |
|---|---|---|
| $sql | mixed | The SQL statement with placeholders. May be a string or Zend_Db_Select. |
| $bind | mixed | An array of data to bind to the placeholders. |
| Type | Description |
|---|---|
| \Zend_Db_Statement_Interface |

quote(mixed $value, mixed $type = null) : mixedSafely quotes a value for an SQL statement.
| Name | Type | Description |
|---|---|---|
| $value | mixed | The value to quote. |
| $type | mixed | OPTIONAL the SQL datatype name, or constant, or null. |
| Type | Description |
|---|---|
| mixed | An SQL-safe quoted value (or string of separated values). |

quoteColumnAs(string | array | \Zend_Db_Expr $ident, string $alias, boolean $auto = false) : stringQuote a column identifier and alias.
| Name | Type | Description |
|---|---|---|
| $ident | string | array | \Zend_Db_Expr | The identifier or expression. |
| $alias | string | An alias for the column. |
| $auto | boolean | If true, heed the AUTO_QUOTE_IDENTIFIERS config option. |
| Type | Description |
|---|---|
| string | The quoted identifier and alias. |

quoteIdentifier(string | array | \Zend_Db_Expr $ident, boolean $auto = false) : stringQuotes an identifier.
$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.| Name | Type | Description |
|---|---|---|
| $ident | string | array | \Zend_Db_Expr | The identifier. |
| $auto | boolean | If true, heed the AUTO_QUOTE_IDENTIFIERS config option. |
| Type | Description |
|---|---|
| string | The quoted identifier. |

quoteInto(string $text, mixed $value, string $type = null, integer $count = null) : stringQuotes a value and places into a piece of text at a placeholder.
$text = "WHERE date < ?";
$date = "2005-01-02";
$safe = $sql->quoteInto($text, $date);
// $safe = "WHERE date < '2005-01-02'"
| Name | Type | Description |
|---|---|---|
| $text | string | The text with a placeholder. |
| $value | mixed | The value to quote. |
| $type | string | OPTIONAL SQL datatype |
| $count | integer | OPTIONAL count of placeholders to replace |
| Type | Description |
|---|---|
| string | An SQL-safe quoted value placed into the original text. |

quoteTableAs(string | array | \Zend_Db_Expr $ident, string $alias = null, boolean $auto = false) : stringQuote a table identifier and alias.
| Name | Type | Description |
|---|---|---|
| $ident | string | array | \Zend_Db_Expr | The identifier or expression. |
| $alias | string | An alias for the table. |
| $auto | boolean | If true, heed the AUTO_QUOTE_IDENTIFIERS config option. |
| Type | Description |
|---|---|
| string | The quoted identifier and alias. |

rollBack() : \Zend_Db_Adapter_AbstractRoll back a transaction and return to autocommit mode.
| Type | Description |
|---|---|
| \Zend_Db_Adapter_Abstract |

select() : \Zend_Db_SelectCreates and returns a new Zend_Db_Select object for this adapter.
| Type | Description |
|---|---|
| \Zend_Db_Select |

setFetchMode(integer $mode) : voidSet the fetch mode.
| Name | Type | Description |
|---|---|---|
| $mode | integer |
| Exception | Description |
|---|---|
| \Zend_Db_Adapter_Exception |

setProfiler(\Zend_Db_Profiler | \Zend_Config | array | boolean $profiler) : \Zend_Db_Adapter_AbstractSet the adapter's profiler object.
| Name | Type | Description |
|---|---|---|
| $profiler | \Zend_Db_Profiler | \Zend_Config | array | boolean |
| Type | Description |
|---|---|
| \Zend_Db_Adapter_Abstract | Provides a fluent interface |
| Exception | Description |
|---|---|
| \Zend_Db_Profiler_Exception | if the object instance or class specified is not Zend_Db_Profiler or an extension of that class. |

setStatementClass( $class) : \Zend_Db_Adapter_AbstractSet the default statement class.
| Name | Type | Description |
|---|---|---|
| $class |
| Type | Description |
|---|---|
| \Zend_Db_Adapter_Abstract | Fluent interface |

supportsParameters(string $type) : boolCheck if the adapter supports real SQL parameters.
| Name | Type | Description |
|---|---|---|
| $type | string | 'positional' or 'named' |
| Type | Description |
|---|---|
| bool |

update(mixed $table, array $bind, mixed $where = '') : intUpdates table rows with specified data based on a WHERE clause.
| Name | Type | Description |
|---|---|---|
| $table | mixed | The table to update. |
| $bind | array | Column-value pairs. |
| $where | mixed | UPDATE WHERE clause(s). |
| Type | Description |
|---|---|
| int | The number of affected rows. |
| Exception | Description |
|---|---|
| \Zend_Db_Adapter_Exception |