Overview

Packages

  • Auth
  • Config
  • Controller
  • Date
  • Db
  • Feed
    • Abstract
    • Writers
  • File
    • Decorator
  • Form
    • Element
  • Image
  • Log
    • Writer
  • Net
    • Exception
    • REST
  • None
  • PHP
  • PHPMailer
  • Session
  • Util
  • Validate
    • Validator
  • Zend
    • Db
      • Adapter
      • Expr
      • Profiler
      • Select
      • Statement
      • Table
    • Loader
      • Autoloader
      • PluginLoader
    • Registry

Classes

  • Zend_Db_Adapter_Abstract
  • 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_Ibm_Db2
  • Zend_Db_Adapter_Pdo_Ibm_Ids
  • 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

Exceptions

  • Zend_Db_Adapter_Db2_Exception
  • Zend_Db_Adapter_Exception
  • Zend_Db_Adapter_Mysqli_Exception
  • Zend_Db_Adapter_Oracle_Exception
  • Zend_Db_Adapter_Sqlsrv_Exception
  • Overview
  • Package
  • Class
  • Tree

Class Zend_Db_Adapter_Abstract

Class for connecting to SQL databases and performing common operations.

Direct known subclasses

Zend_Db_Adapter_Db2, Zend_Db_Adapter_Mysqli, Zend_Db_Adapter_Oracle, Zend_Db_Adapter_Pdo_Abstract, Zend_Db_Adapter_Sqlsrv

Indirect known subclasses

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
Abstract
Package: Zend\Db\Adapter
Category: Zend
Copyright: Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
License: New BSD License
Located at Zend/Db/Adapter/Abstract.php
Methods summary
public
# __construct( array|Zend_Config $config )

Constructor.

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

Parameters

$config
array|Zend_Config
An array or instance of Zend_Config having configuration data

Throws

Zend_Db_Adapter_Exception
protected
# _checkRequiredOptions( array $config )

Check for config options that are mandatory. Throw exceptions if any are missing.

Check for config options that are mandatory. Throw exceptions if any are missing.

Parameters

$config
array

Throws

Zend_Db_Adapter_Exception
public object|resource|null
# getConnection( )

Returns the underlying database connection object or resource. If not presently connected, this initiates the connection.

Returns the underlying database connection object or resource. If not presently connected, this initiates the connection.

Returns

object|resource|null
public array
# getConfig( )

Returns the configuration variables in this adapter.

Returns the configuration variables in this adapter.

Returns

array
public Zend_Db_Adapter_Abstract
# setProfiler( Zend_Db_Profiler|Zend_Config|array|boolean $profiler )

Set the adapter's profiler object.

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.

Parameters

$profiler
Zend_Db_Profiler|Zend_Config|array|boolean

Returns

Zend_Db_Adapter_Abstract
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.
public Zend_Db_Profiler
# getProfiler( )

Returns the profiler for this adapter.

Returns the profiler for this adapter.

Returns

Zend_Db_Profiler
public string
# getStatementClass( )

Get the default statement class.

Get the default statement class.

Returns

string
public Zend_Db_Adapter_Abstract
# setStatementClass( $class )

Set the default statement class.

Set the default statement class.

Returns

Zend_Db_Adapter_Abstract
Fluent interface
public Zend_Db_Statement_Interface
# query( mixed $sql, mixed $bind = array() )

Prepares and executes an SQL statement with bound data.

Prepares and executes an SQL statement with bound data.

Parameters

$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.

Returns

Zend_Db_Statement_Interface
public Zend_Db_Adapter_Abstract
# beginTransaction( )

Leave autocommit mode and begin a transaction.

Leave autocommit mode and begin a transaction.

Returns

Zend_Db_Adapter_Abstract
public Zend_Db_Adapter_Abstract
# commit( )

Commit a transaction and return to autocommit mode.

Commit a transaction and return to autocommit mode.

Returns

Zend_Db_Adapter_Abstract
public Zend_Db_Adapter_Abstract
# rollBack( )

Roll back a transaction and return to autocommit mode.

Roll back a transaction and return to autocommit mode.

Returns

Zend_Db_Adapter_Abstract
public integer
# insert( mixed $table, array $bind )

Inserts a table row with specified data.

Inserts a table row with specified data.

Parameters

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

Returns

integer
The number of affected rows.
public integer
# update( mixed $table, array $bind, mixed $where = '' )

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

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

Parameters

$table
mixed
The table to update.
$bind
array
Column-value pairs.
$where
mixed
UPDATE WHERE clause(s).

Returns

integer
The number of affected rows.
public integer
# delete( mixed $table, mixed $where = '' )

Deletes table rows based on a WHERE clause.

Deletes table rows based on a WHERE clause.

Parameters

$table
mixed
The table to update.
$where
mixed
DELETE WHERE clause(s).

Returns

integer
The number of affected rows.
protected string
# _whereExpr( mixed $where )

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

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

Parameters

$where
mixed

Returns

string
public Zend_Db_Select
# select( )

Creates and returns a new Zend_Db_Select object for this adapter.

Creates and returns a new Zend_Db_Select object for this adapter.

Returns

Zend_Db_Select
public integer
# getFetchMode( )

Get the fetch mode.

Get the fetch mode.

Returns

integer
public array
# fetchAll( string|Zend_Db_Select $sql, mixed $bind = array(), mixed $fetchMode = null )

Fetches all SQL result rows as a sequential array. Uses the current fetchMode for the adapter.

Fetches all SQL result rows as a sequential array. Uses the current fetchMode for the adapter.

Parameters

$sql
string|Zend_Db_Select
An SQL SELECT statement.
$bind
mixed
Data to bind into SELECT placeholders.
$fetchMode
mixed
Override current fetch mode.

Returns

array
public array
# fetchRow( string|Zend_Db_Select $sql, mixed $bind = array(), mixed $fetchMode = null )

Fetches the first row of the SQL result. Uses the current fetchMode for the adapter.

Fetches the first row of the SQL result. Uses the current fetchMode for the adapter.

Parameters

$sql
string|Zend_Db_Select
An SQL SELECT statement.
$bind
mixed
Data to bind into SELECT placeholders.
$fetchMode
mixed
Override current fetch mode.

Returns

array
public array
# fetchAssoc( string|Zend_Db_Select $sql, mixed $bind = array() )

Fetches all SQL result rows as an associative 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.

Parameters

$sql
string|Zend_Db_Select
An SQL SELECT statement.
$bind
mixed
Data to bind into SELECT placeholders.

Returns

array
public array
# fetchCol( string|Zend_Db_Select $sql, mixed $bind = array() )

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

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

Parameters

$sql
string|Zend_Db_Select
An SQL SELECT statement.
$bind
mixed
Data to bind into SELECT placeholders.

Returns

array
public array
# fetchPairs( string|Zend_Db_Select $sql, mixed $bind = array() )

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

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

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

Parameters

$sql
string|Zend_Db_Select
An SQL SELECT statement.
$bind
mixed
Data to bind into SELECT placeholders.

Returns

array
public string
# fetchOne( string|Zend_Db_Select $sql, mixed $bind = array() )

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

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

Parameters

$sql
string|Zend_Db_Select
An SQL SELECT statement.
$bind
mixed
Data to bind into SELECT placeholders.

Returns

string
protected string
# _quote( string $value )

Quote a raw string.

Quote a raw string.

Parameters

$value
string
Raw string

Returns

string
Quoted string
public mixed
# quote( mixed $value, mixed $type = null )

Safely quotes a value for an SQL statement.

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.

Parameters

$value
mixed
The value to quote.
$type
mixed
OPTIONAL the SQL datatype name, or constant, or null.

Returns

mixed
An SQL-safe quoted value (or string of separated values).
public string
# quoteInto( string $text, mixed $value, string $type = null, integer $count = null )

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

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'"

Parameters

$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

Returns

string
An SQL-safe quoted value placed into the original text.
public string
# quoteIdentifier( string|array|Zend_Db_Expr $ident, boolean $auto = false )

Quotes an identifier.

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.

Parameters

$ident
string|array|Zend_Db_Expr
The identifier.
$auto
boolean
If true, heed the AUTO_QUOTE_IDENTIFIERS config option.

Returns

string
The quoted identifier.
public string
# quoteColumnAs( string|array|Zend_Db_Expr $ident, string $alias, boolean $auto = false )

Quote a column identifier and alias.

Quote a column identifier and alias.

Parameters

$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.

Returns

string
The quoted identifier and alias.
public string
# quoteTableAs( string|array|Zend_Db_Expr $ident, string $alias = null, boolean $auto = false )

Quote a table identifier and alias.

Quote a table identifier and alias.

Parameters

$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.

Returns

string
The quoted identifier and alias.
protected string
# _quoteIdentifierAs( string|array|Zend_Db_Expr $ident, string $alias = null, boolean $auto = false, string $as = ' AS ' )

Quote an identifier and an optional alias.

Quote an identifier and an optional alias.

Parameters

$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.

Returns

string
The quoted identifier and alias.
protected string
# _quoteIdentifier( string $value, boolean $auto = false )

Quote an identifier.

Quote an identifier.

Parameters

$value
string
The identifier or expression.
$auto
boolean
If true, heed the AUTO_QUOTE_IDENTIFIERS config option.

Returns

string
The quoted identifier and alias.
public string
# getQuoteIdentifierSymbol( )

Returns the symbol the adapter uses for delimited identifiers.

Returns the symbol the adapter uses for delimited identifiers.

Returns

string
public string
# lastSequenceId( string $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.

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.

Parameters

$sequenceName
string

Returns

string
public string
# nextSequenceId( string $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.

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.

Parameters

$sequenceName
string

Returns

string
public string
# foldCase( string $key )

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

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.

Parameters

$key
string

Returns

string
public array
# __sleep( )

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

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

Returns

array

Throws

Zend_Db_Adapter_Exception
public
# __wakeup( )

called when object is getting unserialized

called when object is getting unserialized

abstract public array
# listTables( )

Returns a list of the tables in the database.

Returns a list of the tables in the database.

Returns

array
abstract public array
# describeTable( string $tableName, string $schemaName = null )

Returns the column descriptions for a table.

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

Parameters

$tableName
string
$schemaName
string
OPTIONAL

Returns

array
abstract protected
# _connect( )

Creates a connection to the database.

Creates a connection to the database.

abstract public boolean
# isConnected( )

Test if a connection is active

Test if a connection is active

Returns

boolean
abstract public
# closeConnection( )

Force the connection to close.

Force the connection to close.

abstract public Zend_Db_Statement|PDOStatement
# prepare( string|Zend_Db_Select $sql )

Prepare a statement and return a PDOStatement-like object.

Prepare a statement and return a PDOStatement-like object.

Parameters

$sql
string|Zend_Db_Select
SQL query

Returns

Zend_Db_Statement|PDOStatement
abstract public string
# lastInsertId( string $tableName = null, string $primaryKey = null )

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

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.

Parameters

$tableName
string
OPTIONAL Name of table.
$primaryKey
string
OPTIONAL Name of primary key column.

Returns

string
abstract protected
# _beginTransaction( )

Begin a transaction.

Begin a transaction.

abstract protected
# _commit( )

Commit a transaction.

Commit a transaction.

abstract protected
# _rollBack( )

Roll-back a transaction.

Roll-back a transaction.

abstract public
# setFetchMode( integer $mode )

Set the fetch mode.

Set the fetch mode.

Parameters

$mode
integer

Throws

Zend_Db_Adapter_Exception
abstract public string
# limit( mixed $sql, integer $count, integer $offset = 0 )

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

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

Parameters

$sql
mixed
$count
integer
$offset
integer

Returns

string
abstract public boolean
# supportsParameters( string $type )

Check if the adapter supports real SQL parameters.

Check if the adapter supports real SQL parameters.

Parameters

$type
string
'positional' or 'named'

Returns

boolean
abstract public string
# getServerVersion( )

Retrieve server version in PHP style

Retrieve server version in PHP style

Returns

string
Properties summary
protected array $_config array()
#

User-provided configuration

User-provided configuration

protected integer $_fetchMode Zend_Db::FETCH_ASSOC
#

Fetch mode

Fetch mode

protected Zend_Db_Profiler $_profiler
#

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

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

protected string $_defaultStmtClass 'Zend_Db_Statement'
#

Default class name for a DB statement.

Default class name for a DB statement.

protected string $_defaultProfilerClass 'Zend_Db_Profiler'
#

Default class name for the profiler object.

Default class name for the profiler object.

protected object|resource|null $_connection null
#

Database connection

Database connection

protected integer $_caseFolding Zend_Db::CASE_NATURAL
#

Specifies the case of column names retrieved in queries Options Zend_Db::CASE_NATURAL (default) Zend_Db::CASE_LOWER Zend_Db::CASE_UPPER

Specifies the case of column names retrieved in queries Options Zend_Db::CASE_NATURAL (default) Zend_Db::CASE_LOWER Zend_Db::CASE_UPPER

protected boolean $_autoQuoteIdentifiers true
#

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().

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().

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 )
#

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

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

Values are: 0 = 32-bit integer 1 = 64-bit integer 2 = float or decimal

protected boolean $_allowSerialization true
#

Weither or not that object can get serialized

Weither or not that object can get serialized

protected boolean $_autoReconnectOnUnserialize false
#

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

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

Pry Framework API documentation generated by ApiGen 2.6.1