Zend Framework
LICENSE
This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.
Class for connecting to SQL databases and performing common operations using PDO.

_connect(
)
:
void
Creates a PDO object and connects to the database.
Exception | Description |
---|---|
\Zend_Db_Adapter_Exception |

_dsn(
)
:
string
Creates a PDO DSN for the adapter from $this->_config settings.
Type | Description |
---|---|
string |

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

exec(
mixed $sql
)
:
integer
Executes an SQL statement and return the number of affected rows
Name | Type | Description |
---|---|---|
$sql | mixed | The SQL statement with placeholders. May be a string or Zend_Db_Select. |
Type | Description |
---|---|
integer | Number of rows that were modified or deleted by the SQL statement |

lastInsertId(
string $tableName
=
null, string $primaryKey
=
null
)
:
string
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.
On RDBMS brands that don't support sequences, $tableName and $primaryKey are ignored.
Name | Type | Description |
---|---|---|
$tableName | string | OPTIONAL Name of table. |
$primaryKey | string | OPTIONAL Name of primary key column. |
Type | Description |
---|---|
string |

prepare(
string $sql
)
:
\PDOStatement
Prepares an SQL statement.
Name | Type | Description |
---|---|---|
$sql | string | The SQL statement with placeholders. |
Type | Description |
---|---|
\PDOStatement |

query(
string|\Zend_Db_Select $sql, array $bind
=
array()
)
:
\Zend_Db_Statement_Pdo
Special handling for PDO query().
All bind parameter names must begin with ':'
Name | Type | Description |
---|---|---|
$sql | string|\Zend_Db_Select | The SQL statement with placeholders. |
$bind | array | An array of data to bind to the placeholders. |
Type | Description |
---|---|
\Zend_Db_Statement_Pdo |
Exception | Description |
---|---|
\Zend_Db_Adapter_Exception | To re-throw PDOException. |

setFetchMode(
int $mode
)
:
void
Set the PDO fetch mode.
Name | Type | Description |
---|---|---|
$mode | int | A PDO fetch mode. |
Exception | Description |
---|---|
\Zend_Db_Adapter_Exception |