Zend Framework  1.12
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Zend_Db_Adapter_Db2 Class Reference

Public Member Functions

 isConnected ()
 Test if a connection is active.
 
 closeConnection ()
 Force the connection to close.
 
 prepare ($sql)
 Returns an SQL statement for preparation.
 
 _getExecuteMode ()
 Gets the execution mode.
 
 _setExecuteMode ($mode)
 
 getQuoteIdentifierSymbol ()
 
 listTables ($schema=null)
 Returns a list of the tables in the database.
 
 describeTable ($tableName, $schemaName=null)
 Returns the column descriptions for a table.
 
 lastSequenceId ($sequenceName)
 Return the most recent value from the specified sequence in the database.
 
 nextSequenceId ($sequenceName)
 Generate a new value from the specified sequence in the database, and return it.
 
 lastInsertId ($tableName=null, $primaryKey=null, $idType=null)
 Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT column.
 
 setFetchMode ($mode)
 Set the fetch mode.
 
 limit ($sql, $count, $offset=0)
 Adds an adapter-specific LIMIT clause to the SELECT statement.
 
 supportsParameters ($type)
 Check if the adapter supports real SQL parameters.
 
 getServerVersion ()
 Retrieve server version in PHP style.
 
 isI5 ()
 Return whether or not this is running on i5.
 
- Public Member Functions inherited from Zend_Db_Adapter_Abstract
 __construct ($config)
 Constructor.
 
 getConnection ()
 Returns the underlying database connection object or resource.
 
 getConfig ()
 Returns the configuration variables in this adapter.
 
 setProfiler ($profiler)
 Set the adapter's profiler object.
 
 getProfiler ()
 Returns the profiler for this adapter.
 
 getStatementClass ()
 Get the default statement class.
 
 setStatementClass ($class)
 Set the default statement class.
 
 query ($sql, $bind=array())
 Prepares and executes an SQL statement with bound data.
 
 beginTransaction ()
 Leave autocommit mode and begin a transaction.
 
 commit ()
 Commit a transaction and return to autocommit mode.
 
 rollBack ()
 Roll back a transaction and return to autocommit mode.
 
 insert ($table, array $bind)
 Inserts a table row with specified data.
 
 update ($table, array $bind, $where= '')
 Updates table rows with specified data based on a WHERE clause.
 
 delete ($table, $where= '')
 Deletes table rows based on a WHERE clause.
 
 select ()
 Creates and returns a new Zend_Db_Select object for this adapter.
 
 getFetchMode ()
 Get the fetch mode.
 
 fetchAll ($sql, $bind=array(), $fetchMode=null)
 Fetches all SQL result rows as a sequential array.
 
 fetchRow ($sql, $bind=array(), $fetchMode=null)
 Fetches the first row of the SQL result.
 
 fetchAssoc ($sql, $bind=array())
 Fetches all SQL result rows as an associative array.
 
 fetchCol ($sql, $bind=array())
 Fetches the first column of all SQL result rows as an array.
 
 fetchPairs ($sql, $bind=array())
 Fetches all SQL result rows as an array of key-value pairs.
 
 fetchOne ($sql, $bind=array())
 Fetches the first column of the first row of the SQL result.
 
 quote ($value, $type=null)
 Safely quotes a value for an SQL statement.
 
 quoteInto ($text, $value, $type=null, $count=null)
 Quotes a value and places into a piece of text at a placeholder.
 
 quoteIdentifier ($ident, $auto=false)
 Quotes an identifier.
 
 quoteColumnAs ($ident, $alias, $auto=false)
 Quote a column identifier and alias.
 
 quoteTableAs ($ident, $alias=null, $auto=false)
 Quote a table identifier and alias.
 
 getQuoteIdentifierSymbol ()
 Returns the symbol the adapter uses for delimited identifiers.
 
 lastSequenceId ($sequenceName)
 Return the most recent value from the specified sequence in the database.
 
 nextSequenceId ($sequenceName)
 Generate a new value from the specified sequence in the database, and return it.
 
 foldCase ($key)
 Helper method to change the case of the strings used when returning result sets in FETCH_ASSOC and FETCH_BOTH modes.
 
 __sleep ()
 called when object is getting serialized This disconnects the DB object that cant be serialized
 
 __wakeup ()
 called when object is getting unserialized
 
 listTables ()
 Abstract Methods.
 
 describeTable ($tableName, $schemaName=null)
 Returns the column descriptions for a table.
 
 isConnected ()
 Test if a connection is active.
 
 closeConnection ()
 Force the connection to close.
 
 prepare ($sql)
 Prepare a statement and return a PDOStatement-like object.
 
 lastInsertId ($tableName=null, $primaryKey=null)
 Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT column.
 
 setFetchMode ($mode)
 Set the fetch mode.
 
 limit ($sql, $count, $offset=0)
 Adds an adapter-specific LIMIT clause to the SELECT statement.
 
 supportsParameters ($type)
 Check if the adapter supports real SQL parameters.
 
 getServerVersion ()
 Retrieve server version in PHP style.
 

Protected Member Functions

 _connect ()
 Creates a connection resource.
 
 _quote ($value)
 Quote a raw string.
 
 _beginTransaction ()
 Begin a transaction.
 
 _commit ()
 Commit a transaction.
 
 _rollBack ()
 Rollback a transaction.
 
 _determineI5 ()
 Check the connection parameters according to verify type of used OS.
 
 _i5listTables ($schema=null)
 Db2 On I5 specific method.
 
 _i5LastInsertId ($objectName=null, $idType=null)
 
- Protected Member Functions inherited from Zend_Db_Adapter_Abstract
 _checkRequiredOptions (array $config)
 Check for config options that are mandatory.
 
 _whereExpr ($where)
 Convert an array, string, or Zend_Db_Expr object into a string to put in a WHERE clause.
 
 _quote ($value)
 Quote a raw string.
 
 _quoteIdentifierAs ($ident, $alias=null, $auto=false, $as= 'AS ')
 Quote an identifier and an optional alias.
 
 _quoteIdentifier ($value, $auto=false)
 Quote an identifier.
 
 _connect ()
 Creates a connection to the database.
 
 _beginTransaction ()
 Begin a transaction.
 
 _commit ()
 Commit a transaction.
 
 _rollBack ()
 Roll-back a transaction.
 

Protected Attributes

 $_config
 
 $_execute_mode = DB2_AUTOCOMMIT_ON
 
 $_defaultStmtClass = 'Zend_Db_Statement_Db2'
 
 $_isI5 = false
 
 $_numericDataTypes
 
- Protected Attributes inherited from Zend_Db_Adapter_Abstract
 $_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
 

Member Function Documentation

_beginTransaction ( )
protected

Begin a transaction.

Returns
void
_commit ( )
protected

Commit a transaction.

Returns
void
See Also
Zend_Db_Adapter_Db2_Exception
_connect ( )
protected

Creates a connection resource.

Returns
void
See Also
Zend_Db_Adapter_Db2_Exception
Zend_Db_Adapter_Db2_Exception
_determineI5 ( )
protected

Check the connection parameters according to verify type of used OS.

Returns
void
_getExecuteMode ( )

Gets the execution mode.

Returns
int the execution mode (DB2_AUTOCOMMIT_ON or DB2_AUTOCOMMIT_OFF)
_i5LastInsertId (   $objectName = null,
  $idType = null 
)
protected
_i5listTables (   $schema = null)
protected

Db2 On I5 specific method.

Returns a list of the tables in the database . Used only for DB2/400.

Returns
array
_quote (   $value)
protected

Quote a raw string.

Parameters
string$valueRaw string
Returns
string Quoted string

Use db2_escape_string() if it is present in the IBM DB2 extension. But some supported versions of PHP do not include this function, so fall back to default quoting in the parent class.

_rollBack ( )
protected

Rollback a transaction.

Returns
void
See Also
Zend_Db_Adapter_Db2_Exception
_setExecuteMode (   $mode)
Parameters
integer$mode
Returns
void
See Also
Zend_Db_Adapter_Db2_Exception
closeConnection ( )

Force the connection to close.

Returns
void
describeTable (   $tableName,
  $schemaName = null 
)

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 DB2 not supports UNSIGNED integer. PRIMARY => boolean; true if column is part of the primary key PRIMARY_POSITION => integer; position of column in primary key IDENTITY => integer; true if column is auto-generated with unique values

Parameters
string$tableName
string$schemaNameOPTIONAL
Returns
array

To avoid case issues, fetch using FETCH_NUM

The ordering of columns is defined by the query so we can map to variables to improve readability

In IBM DB2, an column can be IDENTITY even if it is not part of the PRIMARY KEY.

getQuoteIdentifierSymbol ( )
Returns
string
getServerVersion ( )

Retrieve server version in PHP style.

Returns
string
isConnected ( )

Test if a connection is active.

Returns
boolean
isI5 ( )

Return whether or not this is running on i5.

Returns
bool
lastInsertId (   $tableName = null,
  $primaryKey = null,
  $idType = null 
)

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.

The IDENTITY_VAL_LOCAL() function gives the last generated identity value in the current process, even if it was for a GENERATED column.

Parameters
string$tableNameOPTIONAL
string$primaryKeyOPTIONAL
string$idTypeOPTIONAL used for i5 platform to define sequence/idenity unique value
Returns
string
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.

Parameters
string$sequenceName
Returns
string
limit (   $sql,
  $count,
  $offset = 0 
)

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

Parameters
string$sql
integer$count
integer$offsetOPTIONAL
Returns
string
See Also
Zend_Db_Adapter_Db2_Exception
Zend_Db_Adapter_Db2_Exception

DB2 does not implement the LIMIT clause as some RDBMS do. We have to simulate it with subqueries and ROWNUM. Unfortunately because we use the column wildcard "*", this puts an extra column into the query result set.

listTables (   $schema = null)

Returns a list of the tables in the database.

Parameters
string$schemaOPTIONAL
Returns
array
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.

Parameters
string$sequenceName
Returns
string
prepare (   $sql)

Returns an SQL statement for preparation.

Parameters
string$sqlThe SQL statement with placeholders.
Returns
Zend_Db_Statement_Db2
setFetchMode (   $mode)

Set the fetch mode.

Parameters
integer$mode
Returns
void
Exceptions
Zend_Db_Adapter_Db2_Exception
See Also
Zend_Db_Adapter_Db2_Exception
Zend_Db_Adapter_Db2_Exception
supportsParameters (   $type)

Check if the adapter supports real SQL parameters.

Parameters
string$type'positional' or 'named'
Returns
bool

Member Data Documentation

$_config
protected
Initial value:
= array(
'dbname' => null,
'username' => null,
'password' => null,
'host' => 'localhost',
'port' => '50000',
'protocol' => 'TCPIP',
'persistent' => false,
'os' => null,
'schema' => null
)
$_defaultStmtClass = 'Zend_Db_Statement_Db2'
protected
$_execute_mode = DB2_AUTOCOMMIT_ON
protected
$_isI5 = false
protected
$_numericDataTypes
protected