class DB2Platform extends AbstractPlatform (View source)

Constants

CREATE_INDEXES

CREATE_FOREIGNKEYS

TRIM_UNSPECIFIED

TRIM_LEADING

TRIM_TRAILING

TRIM_BOTH

Properties

protected array $doctrineTypeMapping from AbstractPlatform
protected array $doctrineTypeComments Contains a list of all columns that should generate parseable column comments for type-detection in reverse engineering scenarios. from AbstractPlatform
protected EventManager $_eventManager from AbstractPlatform

Methods

__construct()

Constructor.

setEventManager(EventManager $eventManager)

Sets the EventManager used by the Platform.

EventManager
getEventManager()

Gets the EventManager used by the Platform.

string
getBooleanTypeDeclarationSQL(array $columnDef)

Gets the SQL snippet that declares a boolean column.

string
getIntegerTypeDeclarationSQL(array $columnDef)

Gets the SQL snippet that declares a 4 byte integer column.

string
getBigIntTypeDeclarationSQL(array $columnDef)

Gets the SQL snippet that declares an 8 byte integer column.

string
getSmallIntTypeDeclarationSQL(array $columnDef)

Gets the SQL snippet that declares a 2 byte integer column.

string
_getCommonIntegerTypeDeclarationSQL(array $columnDef)

Gets the SQL snippet that declares common properties of an integer column.

void
initializeDoctrineTypeMappings()

Lazy load Doctrine Type Mappings

getVarcharTypeDeclarationSQL(array $field)

Gets the SQL snippet used to declare a VARCHAR column type.

getVarcharTypeDeclarationSQLSnippet($length, $fixed)

Gets the SQL snippet used to declare a VARCHAR column type.

getClobTypeDeclarationSQL(array $field)

Gets the SQL snippet used to declare a CLOB column type.

getBlobTypeDeclarationSQL(array $field)

Gets the SQL Snippet used to declare a BLOB column type.

string
getName()

Gets the name of the platform.

registerDoctrineTypeMapping(string $dbType, string $doctrineType)

Register a doctrine type to be used in conjunction with a column type of this platform.

string
getDoctrineTypeMapping(string $dbType)

Get the Doctrine type that is mapped for the given database column type.

bool
hasDoctrineTypeMappingFor(string $dbType)

Check if a database type is currently supported by this platform.

void
initializeCommentedDoctrineTypes()

Initialize the Doctrine Type comments instance variable for in_array() checks.

bool
isCommentedDoctrineType(Type $doctrineType)

Is it necessary for the platform to add a parsable type comment to allow reverse engineering the given type?

void
markDoctrineTypeCommented(Type $doctrineType)

Mark this type as to be commented in ALTER TABLE and CREATE TABLE statements.

string
getDoctrineTypeComment(Type $doctrineType)

Get the comment to append to a column comment that helps parsing this type in reverse engineering.

string
getColumnComment(Column $column)

Return the comment of a passed column modified by potential doctrine type comment hints.

string
getIdentifierQuoteCharacter()

Gets the character used for identifier quoting.

string
getSqlCommentStartString()

Gets the string portion that starts an SQL comment.

string
getSqlCommentEndString()

Gets the string portion that ends an SQL comment.

integer
getVarcharMaxLength()

Gets the maximum length of a varchar field.

integer
getVarcharDefaultLength()

Gets the default length of a varchar field.

array
getWildcards()

Gets all SQL wildcard characters of the platform.

string
getRegexpExpression()

Returns the regular expression operator.

string
getGuidExpression()

Returns global unique identifier

string
getAvgExpression(string $column)

Returns the average value of a column

string
getCountExpression(string|integer $column)

Returns the number of rows (without a NULL value) of a column

string
getMaxExpression(string $column)

Returns the highest value of a column

string
getMinExpression(string $column)

Returns the lowest value of a column

string
getSumExpression(string $column)

Returns the total sum of a column

string
getMd5Expression($column)

Returns the md5 sum of a field.

string
getLengthExpression($column)

Returns the length of a text field.

string
getRoundExpression($column, $decimals = 0)

Rounds a numeric field to the number of decimals specified.

string
getModExpression(string $expression1, string $expression2)

Returns the remainder of the division operation $expression1 / $expression2.

string
getTrimExpression(string $str, int $pos = self::TRIM_UNSPECIFIED, string $char = false)

Trim a string, leading/trailing/both and with a given char which defaults to space.

string
getRtrimExpression(string $str)

rtrim returns the string $str with proceeding space characters removed

string
getLtrimExpression(string $str)

ltrim returns the string $str with leading space characters removed

string
getUpperExpression(string $str)

upper Returns the string $str with all characters changed to uppercase according to the current character set mapping.

string
getLowerExpression(string $str)

lower Returns the string $str with all characters changed to lowercase according to the current character set mapping.

integer
getLocateExpression($str, $substr, $startPos = false)

returns the position of the first occurrence of substring $substr in string $str

string
getNowExpression()

Returns the current system date.

string
getSubstringExpression(string $value, integer $from, integer $len = null)

return string to call a function to get a substring inside an SQL statement

string
getConcatExpression()

Returns a series of strings concatinated

string
getNotExpression($expression)

Returns the SQL for a logical not.

string
getInExpression(string $column, string|array(string) $values)

Returns the SQL to check if a value is one in a set of given values.

string
getIsNullExpression(string $expression)

Returns SQL that checks if a expression is null.

string
getIsNotNullExpression(string $expression)

Returns SQL that checks if a expression is not null.

string
getBetweenExpression(string $expression, string $value1, string $value2)

Returns SQL that checks if an expression evaluates to a value between two values.

getAcosExpression($value)

No description

getSinExpression($value)

No description

getPiExpression()

No description

getCosExpression($value)

No description

string
getDateDiffExpression(string $date1, string $date2)

Calculate the difference in days between the two passed dates.

string
getDateAddDaysExpression(string $date, int $days)

Add the number of given days to a date.

string
getDateSubDaysExpression(string $date, int $days)

Substract the number of given days to a date.

string
getDateAddMonthExpression(string $date, int $months)

Add the number of given months to a date.

string
getDateSubMonthExpression(string $date, int $months)

Substract the number of given months to a date.

string
getBitAndComparisonExpression(string $value1, string $value2)

Gets SQL bit AND comparison expression

string
getBitOrComparisonExpression(string $value1, string $value2)

Gets SQL bit OR comparison expression

getForUpdateSQL()

No description

string
appendLockHint(string $fromClause, int $lockMode)

Honors that some SQL vendors such as MsSql use table hints for locking instead of the ANSI SQL FOR UPDATE specification.

string
getReadLockSQL()

Get the sql snippet to append to any SELECT statement which locks rows in shared read lock.

string
getWriteLockSQL()

Get the SQL snippet to append to any SELECT statement which obtains an exclusive lock on the rows.

getDropDatabaseSQL($database)

No description

string
getDropTableSQL(Table|string $table)

Drop a Table

string
getDropTemporaryTableSQL(Table|string $table)

Get SQL to safely drop a temporary table WITHOUT implicitly committing an open transaction.

string
getDropIndexSQL($index, $table = null)

Drop index from a table

string
getDropConstraintSQL(Constraint $constraint, string|Table $table)

Get drop constraint sql

string
getDropForeignKeySQL(ForeignKeyConstraint|string $foreignKey, Table|string $table)

No description

array
getCreateTableSQL(Table $table, int $createFlags = self::CREATE_INDEXES)

Gets the SQL statement(s) to create a table with the specified name, columns and constraints on this platform.

getCommentOnColumnSQL($tableName, $columnName, $comment)

No description

array
_getCreateTableSQL(string $tableName, array $columns, array $options = array())

No description

getCreateSequenceSQL(Sequence $sequence)

Gets the SQL to create a sequence on this platform.

string
getAlterSequenceSQL(Sequence $sequence)

Gets the SQL statement to change a sequence on this platform.

string
getCreateConstraintSQL(Constraint $constraint, string|Table $table)

Gets the SQL to create a constraint on a table on this platform.

string
getCreateIndexSQL(Index $index, string|Table $table)

Gets the SQL to create an index on a table on this platform.

string
getCreatePrimaryKeySQL(Index $index, string|Table $table)

Get SQL to create an unnamed primary key constraint.

string
quoteIdentifier(string $str)

Quotes a string so that it can be safely used as a table or column name, even if it is a reserved word of the platform. This also detects identifier chains seperated by dot and quotes them independently.

string
quoteSingleIdentifier(string $str)

Quote a single identifier (no dot chain seperation)

string
getCreateForeignKeySQL(ForeignKeyConstraint $foreignKey, string|Table $table)

Create a new foreign key

array
getAlterTableSQL(TableDiff $diff)

Gets the SQL to alter an existing table.

onSchemaAlterTableAddColumn(Column $column, TableDiff $diff, array $columnSql)

No description

onSchemaAlterTableRemoveColumn(Column $column, TableDiff $diff, array $columnSql)

No description

onSchemaAlterTableChangeColumn(ColumnDiff $columnDiff, TableDiff $diff, array $columnSql)

No description

onSchemaAlterTableRenameColumn(string $oldColumnName, Column $column, TableDiff $diff, array $columnSql)

No description

onSchemaAlterTable(TableDiff $diff, $sql)

No description

array
_getAlterTableIndexForeignKeySQL(TableDiff $diff)

Common code for alter table statement generation that updates the changed Index and Foreign Key definitions.

string
getColumnDeclarationListSQL(array $fields)

Get declaration of a number of fields in bulk

string
getColumnDeclarationSQL(string $name, array $field)

Obtain DBMS specific SQL code portion needed to declare a generic type field to be used in statements like CREATE TABLE.

string
getDecimalTypeDeclarationSQL(array $columnDef)

Gets the SQL snippet that declares a floating point column of arbitrary precision.

string
getDefaultValueDeclarationSQL(array $field)

Obtain DBMS specific SQL code portion needed to set a default value declaration to be used in statements like CREATE TABLE.

string
getCheckDeclarationSQL(array $definition)

Obtain DBMS specific SQL code portion needed to set a CHECK constraint declaration to be used in statements like CREATE TABLE.

string
getUniqueConstraintDeclarationSQL(string $name, Index $index)

Obtain DBMS specific SQL code portion needed to set a unique constraint declaration to be used in statements like CREATE TABLE.

string
getIndexDeclarationSQL(string $name, Index $index)

Obtain DBMS specific SQL code portion needed to set an index declaration to be used in statements like CREATE TABLE.

string
getCustomTypeDeclarationSQL(array $columnDef)

getCustomTypeDeclarationSql Obtail SQL code portion needed to create a custom column, e.g. when a field has the "columnDefinition" keyword.

string
getIndexFieldDeclarationListSQL(array $fields)

getIndexFieldDeclarationList Obtain DBMS specific SQL code portion needed to set an index declaration to be used in statements like CREATE TABLE.

string
getTemporaryTableSQL()

A method to return the required SQL string that fits between CREATE .

string
getTemporaryTableName(string $tableName)

DB2 automatically moves temporary tables into the SESSION. schema.

string
getShowDatabasesSQL()

Get sql query to show a list of database.

string
getForeignKeyDeclarationSQL(ForeignKeyConstraint $foreignKey)

Obtain DBMS specific SQL code portion needed to set the FOREIGN KEY constraint of a field declaration to be used in statements like CREATE TABLE.

string
getAdvancedForeignKeyOptionsSQL(ForeignKeyConstraint $foreignKey)

Return the FOREIGN KEY query section dealing with non-standard options as MATCH, INITIALLY DEFERRED, ON UPDATE, .

getForeignKeyReferentialActionSQL($action)

returns given referential action in uppercase if valid, otherwise throws an exception

string
getForeignKeyBaseDeclarationSQL(ForeignKeyConstraint $foreignKey)

Obtain DBMS specific SQL code portion needed to set the FOREIGN KEY constraint of a field declaration to be used in statements like CREATE TABLE.

string
getUniqueFieldDeclarationSQL()

Obtain DBMS specific SQL code portion needed to set the UNIQUE constraint of a field declaration to be used in statements like CREATE TABLE.

string
getColumnCharsetDeclarationSQL(string $charset)

Obtain DBMS specific SQL code portion needed to set the CHARACTER SET of a field declaration to be used in statements like CREATE TABLE.

string
getColumnCollationDeclarationSQL(string $collation)

Obtain DBMS specific SQL code portion needed to set the COLLATION of a field declaration to be used in statements like CREATE TABLE.

boolean
prefersSequences()

Whether the platform prefers sequences for ID generation.

boolean
prefersIdentityColumns()

Whether the platform prefers identity columns (eg. autoincrement) for ID generation.

convertBooleans(mixed $item)

Some platforms need the boolean values to be converted.

string
getSetCharsetSQL(string $charset)

Gets the SQL statement specific for the platform to set the charset.

string
getCurrentDateSQL()

Gets the SQL specific for the platform to get the current date.

string
getCurrentTimeSQL()

Gets the SQL specific for the platform to get the current time.

string
getCurrentTimestampSQL()

Gets the SQL specific for the platform to get the current timestamp

_getTransactionIsolationLevelSQL(integer $level)

Get sql for transaction isolation level Connection constant

getListDatabasesSQL()

No description

getListSequencesSQL($database)

No description

getListTableConstraintsSQL($table)

No description

getListTableColumnsSQL($table, $database = null)

This code fragment is originally from the Zend_Db_Adapter_Db2 class.

getListTablesSQL()

No description

getListUsersSQL()

No description

string
getListViewsSQL(string $database)

Get the SQL to list all views of a database or user.

getListTableIndexesSQL(string $table, string $currentDatabase = null)

Get the list of indexes for the current database.

getListTableForeignKeysSQL($table)

No description

getCreateViewSQL($name, $sql)

No description

getDropViewSQL($name)

No description

getDropSequenceSQL($sequence)

No description

getSequenceNextValSQL($sequenceName)

No description

getCreateDatabaseSQL($database)

No description

getSetTransactionIsolationSQL(integer $level)

Get sql to set the transaction isolation level

string
getDateTimeTypeDeclarationSQL(array $fieldDeclaration)

Obtain DBMS specific SQL to be used to create datetime fields in statements like CREATE TABLE

getDateTimeTzTypeDeclarationSQL(array $fieldDeclaration)

Obtain DBMS specific SQL to be used to create datetime with timezone offset fields.

string
getDateTypeDeclarationSQL(array $fieldDeclaration)

Obtain DBMS specific SQL to be used to create date fields in statements like CREATE TABLE.

string
getTimeTypeDeclarationSQL(array $fieldDeclaration)

Obtain DBMS specific SQL to be used to create time fields in statements like CREATE TABLE.

getFloatDeclarationSQL(array $fieldDeclaration)

No description

integer
getDefaultTransactionIsolationLevel()

Gets the default transaction isolation level of the platform.

boolean
supportsSequences()

Whether the platform supports sequences.

boolean
supportsIdentityColumns()

Whether the platform supports identity columns.

boolean
supportsIndexes()

Whether the platform supports indexes.

supportsAlterTable()

No description

boolean
supportsTransactions()

Whether the platform supports transactions.

boolean
supportsSavepoints()

DB2 supports savepoints, but they work semantically different than on other vendor platforms.

boolean
supportsReleaseSavepoints()

Whether the platform supports releasing savepoints.

boolean
supportsPrimaryConstraints()

Whether the platform supports primary key constraints.

boolean
supportsForeignKeyConstraints()

Does the platform supports foreign key constraints?

bool
supportsForeignKeyOnUpdate()

Does this platform supports onUpdate in foreign key constraints?

boolean
supportsSchemas()

Whether the platform supports database schemas.

bool
canEmulateSchemas()

Can this platform emulate schemas?

bool
supportsCreateDropDatabase()

Some databases don't allow to create and drop databases at all or only with certain tools.

boolean
supportsGettingAffectedRows()

Whether the platform supports getting the affected rows of a recent update/delete type query.

bool
supportsInlineColumnComments()

Does this plaform support to add inline column comments as postfix.

bool
supportsCommentOnStatement()

Does this platform support the propriortary synatx "COMMENT ON asset"

string
getDateTimeFormatString()

Gets the format string, as accepted by the date() function, that describes the format of a stored datetime value of this platform.

string
getDateTimeTzFormatString()

Gets the format string, as accepted by the date() function, that describes the format of a stored datetime with timezone value of this platform.

string
getDateFormatString()

Gets the format string, as accepted by the date() function, that describes the format of a stored date value of this platform.

string
getTimeFormatString()

Gets the format string, as accepted by the date() function, that describes the format of a stored time value of this platform.

string
modifyLimitQuery(string $query, int $limit, int $offset = null)

Modify limit query

string
doModifyLimitQuery(string $query, int $limit, int $offset = null)

No description

bool
supportsLimitOffset()

Does the database platform support offsets in modify limit clauses?

string
getSQLResultCasing(string $column)

Gets the character casing of a column in an SQL result set of this platform.

string
fixSchemaElementName($schemaElementName)

Makes any fixes to a name of a schema element (table, sequence, .

int
getMaxIdentifierLength()

Maximum length of any given databse identifier, like tables or column names.

string
getEmptyIdentityInsertSQL(string $tableName, string $identifierColumnName)

Get the insert sql for an empty insert statement

string
getTruncateTableSQL(string $tableName, bool $cascade = false)

Generate a Truncate Table SQL statement for a given table.

string
getDummySelectSQL()

This is for test reasons, many vendors have special requirements for dummy statements.

string
createSavePoint(string $savepoint)

Generate SQL to create a new savepoint

string
releaseSavePoint(string $savepoint)

Generate SQL to release a savepoint

string
rollbackSavePoint(string $savepoint)

Generate SQL to rollback a savepoint

KeywordList
getReservedKeywordsList()

Return the keyword list instance of this platform.

string
getReservedKeywordsClass()

The class name of the reserved keywords list.

Details

__construct()

Constructor.

setEventManager(EventManager $eventManager)

Sets the EventManager used by the Platform.

Parameters

EventManager $eventManager

EventManager getEventManager()

Gets the EventManager used by the Platform.

Return Value

EventManager

string getBooleanTypeDeclarationSQL(array $columnDef)

Gets the SQL snippet that declares a boolean column.

Parameters

array $columnDef

Return Value

string

string getIntegerTypeDeclarationSQL(array $columnDef)

Gets the SQL snippet that declares a 4 byte integer column.

Parameters

array $columnDef

Return Value

string

string getBigIntTypeDeclarationSQL(array $columnDef)

Gets the SQL snippet that declares an 8 byte integer column.

Parameters

array $columnDef

Return Value

string

string getSmallIntTypeDeclarationSQL(array $columnDef)

Gets the SQL snippet that declares a 2 byte integer column.

Parameters

array $columnDef

Return Value

string

protected string _getCommonIntegerTypeDeclarationSQL(array $columnDef)

Gets the SQL snippet that declares common properties of an integer column.

Parameters

array $columnDef

Return Value

string

void initializeDoctrineTypeMappings()

Lazy load Doctrine Type Mappings

Return Value

void

getVarcharTypeDeclarationSQL(array $field)

Gets the SQL snippet used to declare a VARCHAR column type.

Parameters

array $field

protected getVarcharTypeDeclarationSQLSnippet($length, $fixed)

Gets the SQL snippet used to declare a VARCHAR column type.

Parameters

$length
$fixed

getClobTypeDeclarationSQL(array $field)

Gets the SQL snippet used to declare a CLOB column type.

Parameters

array $field

getBlobTypeDeclarationSQL(array $field)

Gets the SQL Snippet used to declare a BLOB column type.

Parameters

array $field

string getName()

Gets the name of the platform.

Return Value

string

registerDoctrineTypeMapping(string $dbType, string $doctrineType)

Register a doctrine type to be used in conjunction with a column type of this platform.

Parameters

string $dbType
string $doctrineType

string getDoctrineTypeMapping(string $dbType)

Get the Doctrine type that is mapped for the given database column type.

Parameters

string $dbType

Return Value

string

bool hasDoctrineTypeMappingFor(string $dbType)

Check if a database type is currently supported by this platform.

Parameters

string $dbType

Return Value

bool

protected void initializeCommentedDoctrineTypes()

Initialize the Doctrine Type comments instance variable for in_array() checks.

Return Value

void

bool isCommentedDoctrineType(Type $doctrineType)

Is it necessary for the platform to add a parsable type comment to allow reverse engineering the given type?

Parameters

Type $doctrineType

Return Value

bool

void markDoctrineTypeCommented(Type $doctrineType)

Mark this type as to be commented in ALTER TABLE and CREATE TABLE statements.

Parameters

Type $doctrineType

Return Value

void

string getDoctrineTypeComment(Type $doctrineType)

Get the comment to append to a column comment that helps parsing this type in reverse engineering.

Parameters

Type $doctrineType

Return Value

string

protected string getColumnComment(Column $column)

Return the comment of a passed column modified by potential doctrine type comment hints.

Parameters

Column $column

Return Value

string

string getIdentifierQuoteCharacter()

Gets the character used for identifier quoting.

Return Value

string

string getSqlCommentStartString()

Gets the string portion that starts an SQL comment.

Return Value

string

string getSqlCommentEndString()

Gets the string portion that ends an SQL comment.

Return Value

string

integer getVarcharMaxLength()

Gets the maximum length of a varchar field.

Return Value

integer

integer getVarcharDefaultLength()

Gets the default length of a varchar field.

Return Value

integer

array getWildcards()

Gets all SQL wildcard characters of the platform.

Return Value

array

string getRegexpExpression()

Returns the regular expression operator.

Return Value

string

string getGuidExpression()

Returns global unique identifier

Return Value

string to get global unique identifier

string getAvgExpression(string $column)

Returns the average value of a column

Parameters

string $column the column to use

Return Value

string generated sql including an AVG aggregate function

string getCountExpression(string|integer $column)

Returns the number of rows (without a NULL value) of a column

If a '*' is used instead of a column the number of selected rows is returned.

Parameters

string|integer $column the column to use

Return Value

string generated sql including a COUNT aggregate function

string getMaxExpression(string $column)

Returns the highest value of a column

Parameters

string $column the column to use

Return Value

string generated sql including a MAX aggregate function

string getMinExpression(string $column)

Returns the lowest value of a column

Parameters

string $column the column to use

Return Value

string

string getSumExpression(string $column)

Returns the total sum of a column

Parameters

string $column the column to use

Return Value

string

string getMd5Expression($column)

Returns the md5 sum of a field.

Note: Not SQL92, but common functionality

Parameters

$column

Return Value

string

string getLengthExpression($column)

Returns the length of a text field.

Parameters

$column

Return Value

string

string getRoundExpression($column, $decimals = 0)

Rounds a numeric field to the number of decimals specified.

Parameters

$column
$decimals

Return Value

string

string getModExpression(string $expression1, string $expression2)

Returns the remainder of the division operation $expression1 / $expression2.

Parameters

string $expression1
string $expression2

Return Value

string

string getTrimExpression(string $str, int $pos = self::TRIM_UNSPECIFIED, string $char = false)

Trim a string, leading/trailing/both and with a given char which defaults to space.

Parameters

string $str
int $pos
string $char has to be quoted already

Return Value

string

string getRtrimExpression(string $str)

rtrim returns the string $str with proceeding space characters removed

Parameters

string $str literal string or column name

Return Value

string

string getLtrimExpression(string $str)

ltrim returns the string $str with leading space characters removed

Parameters

string $str literal string or column name

Return Value

string

string getUpperExpression(string $str)

upper Returns the string $str with all characters changed to uppercase according to the current character set mapping.

Parameters

string $str literal string or column name

Return Value

string

string getLowerExpression(string $str)

lower Returns the string $str with all characters changed to lowercase according to the current character set mapping.

Parameters

string $str literal string or column name

Return Value

string

integer getLocateExpression($str, $substr, $startPos = false)

returns the position of the first occurrence of substring $substr in string $str

Parameters

$str
$substr
$startPos

Return Value

integer

string getNowExpression()

Returns the current system date.

Return Value

string

string getSubstringExpression(string $value, integer $from, integer $len = null)

return string to call a function to get a substring inside an SQL statement

Note: Not SQL92, but common functionality.

SQLite only supports the 2 parameter variant of this function

Parameters

string $value an sql string literal or column name/alias
integer $from where to start the substring portion
integer $len the substring portion length

Return Value

string

string getConcatExpression()

Returns a series of strings concatinated

concat() accepts an arbitrary number of parameters. Each parameter must contain an expression

Return Value

string

string getNotExpression($expression)

Returns the SQL for a logical not.

Example: $q = new Doctrine_Query(); $e = $q->expr; $q->select('*')->from('table') ->where($e->eq('id', $e->not('null'));

Parameters

$expression

Return Value

string a logical expression

string getInExpression(string $column, string|array(string) $values)

Returns the SQL to check if a value is one in a set of given values.

in() accepts an arbitrary number of parameters. The first parameter must always specify the value that should be matched against. Successive must contain a logical expression or an array with logical expressions. These expressions will be matched against the first parameter.

Parameters

string $column the value that should be matched against
string|array(string) $values values that will be matched against $column

Return Value

string logical expression

string getIsNullExpression(string $expression)

Returns SQL that checks if a expression is null.

Parameters

string $expression the expression that should be compared to null

Return Value

string logical expression

string getIsNotNullExpression(string $expression)

Returns SQL that checks if a expression is not null.

Parameters

string $expression the expression that should be compared to null

Return Value

string logical expression

string getBetweenExpression(string $expression, string $value1, string $value2)

Returns SQL that checks if an expression evaluates to a value between two values.

The parameter $expression is checked if it is between $value1 and $value2.

Note: There is a slight difference in the way BETWEEN works on some databases. http://www.w3schools.com/sql/sql_between.asp. If you want complete database independence you should avoid using between().

Parameters

string $expression the value to compare to
string $value1 the lower value to compare with
string $value2 the higher value to compare with

Return Value

string logical expression

getAcosExpression($value)

Parameters

$value

getSinExpression($value)

Parameters

$value

getPiExpression()

getCosExpression($value)

Parameters

$value

string getDateDiffExpression(string $date1, string $date2)

Calculate the difference in days between the two passed dates.

Computes diff = date1 - date2

Parameters

string $date1
string $date2

Return Value

string

string getDateAddDaysExpression(string $date, int $days)

Add the number of given days to a date.

Parameters

string $date
int $days

Return Value

string

string getDateSubDaysExpression(string $date, int $days)

Substract the number of given days to a date.

Parameters

string $date
int $days

Return Value

string

string getDateAddMonthExpression(string $date, int $months)

Add the number of given months to a date.

Parameters

string $date
int $months

Return Value

string

string getDateSubMonthExpression(string $date, int $months)

Substract the number of given months to a date.

Parameters

string $date
int $months

Return Value

string

string getBitAndComparisonExpression(string $value1, string $value2)

Gets SQL bit AND comparison expression

Parameters

string $value1
string $value2

Return Value

string

string getBitOrComparisonExpression(string $value1, string $value2)

Gets SQL bit OR comparison expression

Parameters

string $value1
string $value2

Return Value

string

getForUpdateSQL()

string appendLockHint(string $fromClause, int $lockMode)

Honors that some SQL vendors such as MsSql use table hints for locking instead of the ANSI SQL FOR UPDATE specification.

Parameters

string $fromClause
int $lockMode

Return Value

string

string getReadLockSQL()

Get the sql snippet to append to any SELECT statement which locks rows in shared read lock.

This defaults to the ASNI SQL "FOR UPDATE", which is an exclusive lock (Write). Some database vendors allow to lighten this constraint up to be a real read lock.

Return Value

string

string getWriteLockSQL()

Get the SQL snippet to append to any SELECT statement which obtains an exclusive lock on the rows.

The semantics of this lock mode should equal the SELECT .. FOR UPDATE of the ASNI SQL standard.

Return Value

string

getDropDatabaseSQL($database)

Parameters

$database

string getDropTableSQL(Table|string $table)

Drop a Table

Parameters

Table|string $table

Return Value

string

Exceptions

InvalidArgumentException

string getDropTemporaryTableSQL(Table|string $table)

Get SQL to safely drop a temporary table WITHOUT implicitly committing an open transaction.

Parameters

Table|string $table

Return Value

string

string getDropIndexSQL($index, $table = null)

Drop index from a table

Parameters

$index
$table

Return Value

string

string getDropConstraintSQL(Constraint $constraint, string|Table $table)

Get drop constraint sql

Parameters

Constraint $constraint
string|Table $table

Return Value

string

string getDropForeignKeySQL(ForeignKeyConstraint|string $foreignKey, Table|string $table)

Parameters

ForeignKeyConstraint|string $foreignKey
Table|string $table

Return Value

string

array getCreateTableSQL(Table $table, int $createFlags = self::CREATE_INDEXES)

Gets the SQL statement(s) to create a table with the specified name, columns and constraints on this platform.

Parameters

Table $table The name of the table.
int $createFlags

Return Value

array The sequence of SQL statements.

getCommentOnColumnSQL($tableName, $columnName, $comment)

Parameters

$tableName
$columnName
$comment

protected array _getCreateTableSQL(string $tableName, array $columns, array $options = array())

Parameters

string $tableName
array $columns
array $options

Return Value

array

getCreateTemporaryTableSnippetSQL()

getCreateSequenceSQL(Sequence $sequence)

Gets the SQL to create a sequence on this platform.

Parameters

Sequence $sequence

Exceptions

DBALException

string getAlterSequenceSQL(Sequence $sequence)

Gets the SQL statement to change a sequence on this platform.

Parameters

Sequence $sequence

Return Value

string

string getCreateConstraintSQL(Constraint $constraint, string|Table $table)

Gets the SQL to create a constraint on a table on this platform.

Parameters

Constraint $constraint
string|Table $table

Return Value

string

string getCreateIndexSQL(Index $index, string|Table $table)

Gets the SQL to create an index on a table on this platform.

Parameters

Index $index
string|Table $table name of the table on which the index is to be created

Return Value

string

string getCreatePrimaryKeySQL(Index $index, string|Table $table)

Get SQL to create an unnamed primary key constraint.

Parameters

Index $index
string|Table $table

Return Value

string

string quoteIdentifier(string $str)

Quotes a string so that it can be safely used as a table or column name, even if it is a reserved word of the platform. This also detects identifier chains seperated by dot and quotes them independently.

NOTE: Just because you CAN use quoted identifiers doesn't mean you SHOULD use them. In general, they end up causing way more problems than they solve.

Parameters

string $str identifier name to be quoted

Return Value

string quoted identifier string

string quoteSingleIdentifier(string $str)

Quote a single identifier (no dot chain seperation)

Parameters

string $str

Return Value

string

string getCreateForeignKeySQL(ForeignKeyConstraint $foreignKey, string|Table $table)

Create a new foreign key

Parameters

ForeignKeyConstraint $foreignKey ForeignKey instance
string|Table $table name of the table on which the foreign key is to be created

Return Value

string

array getAlterTableSQL(TableDiff $diff)

Gets the SQL to alter an existing table.

Parameters

TableDiff $diff

Return Value

array

protected onSchemaAlterTableAddColumn(Column $column, TableDiff $diff, array $columnSql)

Parameters

Column $column
TableDiff $diff
array $columnSql

protected onSchemaAlterTableRemoveColumn(Column $column, TableDiff $diff, array $columnSql)

Parameters

Column $column
TableDiff $diff
array $columnSql

protected onSchemaAlterTableChangeColumn(ColumnDiff $columnDiff, TableDiff $diff, array $columnSql)

Parameters

ColumnDiff $columnDiff
TableDiff $diff
array $columnSql

protected onSchemaAlterTableRenameColumn(string $oldColumnName, Column $column, TableDiff $diff, array $columnSql)

Parameters

string $oldColumnName
Column $column
TableDiff $diff
array $columnSql

protected onSchemaAlterTable(TableDiff $diff, $sql)

Parameters

TableDiff $diff
$sql

protected getPreAlterTableIndexForeignKeySQL(TableDiff $diff)

Parameters

TableDiff $diff

protected getPostAlterTableIndexForeignKeySQL(TableDiff $diff)

Parameters

TableDiff $diff

protected array _getAlterTableIndexForeignKeySQL(TableDiff $diff)

Common code for alter table statement generation that updates the changed Index and Foreign Key definitions.

Parameters

TableDiff $diff

Return Value

array

string getColumnDeclarationListSQL(array $fields)

Get declaration of a number of fields in bulk

Parameters

array $fields a multidimensional associative array. The first dimension determines the field name, while the second dimension is keyed with the name of the properties of the field being declared as array indexes. Currently, the types of supported field properties are as follows:

 length
     Integer value that determines the maximum length of the text
     field. If this argument is missing the field should be
     declared to have the longest length allowed by the DBMS.

 default
     Text value to be used as default for this field.

 notnull
     Boolean flag that indicates whether this field is constrained
     to not be set to null.
 charset
     Text value with the default CHARACTER SET for this field.
 collation
     Text value with the default COLLATION for this field.
 unique
     unique constraint

Return Value

string

string getColumnDeclarationSQL(string $name, array $field)

Obtain DBMS specific SQL code portion needed to declare a generic type field to be used in statements like CREATE TABLE.

Parameters

string $name name the field to be declared.
array $field associative array with the name of the properties of the field being declared as array indexes. Currently, the types of supported field properties are as follows:

 length
     Integer value that determines the maximum length of the text
     field. If this argument is missing the field should be
     declared to have the longest length allowed by the DBMS.

 default
     Text value to be used as default for this field.

 notnull
     Boolean flag that indicates whether this field is constrained
     to not be set to null.
 charset
     Text value with the default CHARACTER SET for this field.
 collation
     Text value with the default COLLATION for this field.
 unique
     unique constraint
 check
     column check constraint
 columnDefinition
     a string that defines the complete column

Return Value

string DBMS specific SQL code portion that should be used to declare the column.

string getDecimalTypeDeclarationSQL(array $columnDef)

Gets the SQL snippet that declares a floating point column of arbitrary precision.

Parameters

array $columnDef

Return Value

string

string getDefaultValueDeclarationSQL(array $field)

Obtain DBMS specific SQL code portion needed to set a default value declaration to be used in statements like CREATE TABLE.

Parameters

array $field field definition array

Return Value

string DBMS specific SQL code portion needed to set a default value

string getCheckDeclarationSQL(array $definition)

Obtain DBMS specific SQL code portion needed to set a CHECK constraint declaration to be used in statements like CREATE TABLE.

Parameters

array $definition check definition

Return Value

string DBMS specific SQL code portion needed to set a CHECK constraint

string getUniqueConstraintDeclarationSQL(string $name, Index $index)

Obtain DBMS specific SQL code portion needed to set a unique constraint declaration to be used in statements like CREATE TABLE.

Parameters

string $name name of the unique constraint
Index $index index definition

Return Value

string DBMS specific SQL code portion needed to set a constraint

string getIndexDeclarationSQL(string $name, Index $index)

Obtain DBMS specific SQL code portion needed to set an index declaration to be used in statements like CREATE TABLE.

Parameters

string $name name of the index
Index $index index definition

Return Value

string DBMS specific SQL code portion needed to set an index

string getCustomTypeDeclarationSQL(array $columnDef)

getCustomTypeDeclarationSql Obtail SQL code portion needed to create a custom column, e.g. when a field has the "columnDefinition" keyword.

Only "AUTOINCREMENT" and "PRIMARY KEY" are added if appropriate.

Parameters

array $columnDef

Return Value

string

string getIndexFieldDeclarationListSQL(array $fields)

getIndexFieldDeclarationList Obtain DBMS specific SQL code portion needed to set an index declaration to be used in statements like CREATE TABLE.

Parameters

array $fields

Return Value

string

string getTemporaryTableSQL()

A method to return the required SQL string that fits between CREATE .

.. TABLE to create the table as a temporary table.

Should be overridden in driver classes to return the correct string for the specific database type.

The default is to return the string "TEMPORARY" - this will result in a SQL error for any database that does not support temporary tables, or that requires a different SQL command from "CREATE TEMPORARY TABLE".

Return Value

string The string required to be placed between "CREATE" and "TABLE" to generate a temporary table, if possible.

string getTemporaryTableName(string $tableName)

DB2 automatically moves temporary tables into the SESSION. schema.

Parameters

string $tableName

Return Value

string

string getShowDatabasesSQL()

Get sql query to show a list of database.

Return Value

string

string getForeignKeyDeclarationSQL(ForeignKeyConstraint $foreignKey)

Obtain DBMS specific SQL code portion needed to set the FOREIGN KEY constraint of a field declaration to be used in statements like CREATE TABLE.

Parameters

ForeignKeyConstraint $foreignKey

Return Value

string DBMS specific SQL code portion needed to set the FOREIGN KEY constraint of a field declaration.

string getAdvancedForeignKeyOptionsSQL(ForeignKeyConstraint $foreignKey)

Return the FOREIGN KEY query section dealing with non-standard options as MATCH, INITIALLY DEFERRED, ON UPDATE, .

..

Parameters

ForeignKeyConstraint $foreignKey foreign key definition

Return Value

string

getForeignKeyReferentialActionSQL($action)

returns given referential action in uppercase if valid, otherwise throws an exception

Parameters

$action

Exceptions

Doctrine_Exception_Exception if unknown referential action given

string getForeignKeyBaseDeclarationSQL(ForeignKeyConstraint $foreignKey)

Obtain DBMS specific SQL code portion needed to set the FOREIGN KEY constraint of a field declaration to be used in statements like CREATE TABLE.

Parameters

ForeignKeyConstraint $foreignKey

Return Value

string

string getUniqueFieldDeclarationSQL()

Obtain DBMS specific SQL code portion needed to set the UNIQUE constraint of a field declaration to be used in statements like CREATE TABLE.

Return Value

string DBMS specific SQL code portion needed to set the UNIQUE constraint of a field declaration.

string getColumnCharsetDeclarationSQL(string $charset)

Obtain DBMS specific SQL code portion needed to set the CHARACTER SET of a field declaration to be used in statements like CREATE TABLE.

Parameters

string $charset name of the charset

Return Value

string DBMS specific SQL code portion needed to set the CHARACTER SET of a field declaration.

string getColumnCollationDeclarationSQL(string $collation)

Obtain DBMS specific SQL code portion needed to set the COLLATION of a field declaration to be used in statements like CREATE TABLE.

Parameters

string $collation name of the collation

Return Value

string DBMS specific SQL code portion needed to set the COLLATION of a field declaration.

boolean prefersSequences()

Whether the platform prefers sequences for ID generation.

Subclasses should override this method to return TRUE if they prefer sequences.

Return Value

boolean

boolean prefersIdentityColumns()

Whether the platform prefers identity columns (eg. autoincrement) for ID generation.

Subclasses should override this method to return TRUE if they prefer identity columns.

Return Value

boolean

convertBooleans(mixed $item)

Some platforms need the boolean values to be converted.

The default conversion in this implementation converts to integers (false => 0, true => 1).

Parameters

mixed $item

string getSetCharsetSQL(string $charset)

Gets the SQL statement specific for the platform to set the charset.

This function is MySQL specific and required by {see \Doctrine\DBAL\Connection::setCharset($charset)}

Parameters

string $charset

Return Value

string

string getCurrentDateSQL()

Gets the SQL specific for the platform to get the current date.

Return Value

string

string getCurrentTimeSQL()

Gets the SQL specific for the platform to get the current time.

Return Value

string

string getCurrentTimestampSQL()

Gets the SQL specific for the platform to get the current timestamp

Return Value

string

protected _getTransactionIsolationLevelSQL(integer $level)

Get sql for transaction isolation level Connection constant

Parameters

integer $level

getListDatabasesSQL()

getListSequencesSQL($database)

Parameters

$database

getListTableConstraintsSQL($table)

Parameters

$table

getListTableColumnsSQL($table, $database = null)

This code fragment is originally from the Zend_Db_Adapter_Db2 class.

Parameters

$table
$database

getListTablesSQL()

getListUsersSQL()

string getListViewsSQL(string $database)

Get the SQL to list all views of a database or user.

Parameters

string $database

Return Value

string

getListTableIndexesSQL(string $table, string $currentDatabase = null)

Get the list of indexes for the current database.

The current database parameter is optional but will always be passed when using the SchemaManager API and is the database the given table is in.

Attention: Some platforms only support currentDatabase when they are connected with that database. Cross-database information schema requests may be impossible.

Parameters

string $table
string $currentDatabase

getListTableForeignKeysSQL($table)

Parameters

$table

getCreateViewSQL($name, $sql)

Parameters

$name
$sql

getDropViewSQL($name)

Parameters

$name

getDropSequenceSQL($sequence)

Parameters

$sequence

getSequenceNextValSQL($sequenceName)

Parameters

$sequenceName

getCreateDatabaseSQL($database)

Parameters

$database

getSetTransactionIsolationSQL(integer $level)

Get sql to set the transaction isolation level

Parameters

integer $level

string getDateTimeTypeDeclarationSQL(array $fieldDeclaration)

Obtain DBMS specific SQL to be used to create datetime fields in statements like CREATE TABLE

Parameters

array $fieldDeclaration

Return Value

string

getDateTimeTzTypeDeclarationSQL(array $fieldDeclaration)

Obtain DBMS specific SQL to be used to create datetime with timezone offset fields.

Parameters

array $fieldDeclaration

string getDateTypeDeclarationSQL(array $fieldDeclaration)

Obtain DBMS specific SQL to be used to create date fields in statements like CREATE TABLE.

Parameters

array $fieldDeclaration

Return Value

string

string getTimeTypeDeclarationSQL(array $fieldDeclaration)

Obtain DBMS specific SQL to be used to create time fields in statements like CREATE TABLE.

Parameters

array $fieldDeclaration

Return Value

string

getFloatDeclarationSQL(array $fieldDeclaration)

Parameters

array $fieldDeclaration

integer getDefaultTransactionIsolationLevel()

Gets the default transaction isolation level of the platform.

Return Value

integer The default isolation level.

See also

TRANSACTION_* constants.

boolean supportsSequences()

Whether the platform supports sequences.

Return Value

boolean

boolean supportsIdentityColumns()

Whether the platform supports identity columns.

Identity columns are columns that recieve an auto-generated value from the database on insert of a row.

Return Value

boolean

boolean supportsIndexes()

Whether the platform supports indexes.

Return Value

boolean

supportsAlterTable()

boolean supportsTransactions()

Whether the platform supports transactions.

Return Value

boolean

boolean supportsSavepoints()

DB2 supports savepoints, but they work semantically different than on other vendor platforms.

TODO: We have to investigate how to get DB2 up and running with savepoints.

Return Value

boolean

boolean supportsReleaseSavepoints()

Whether the platform supports releasing savepoints.

Return Value

boolean

boolean supportsPrimaryConstraints()

Whether the platform supports primary key constraints.

Return Value

boolean

boolean supportsForeignKeyConstraints()

Does the platform supports foreign key constraints?

Return Value

boolean

bool supportsForeignKeyOnUpdate()

Does this platform supports onUpdate in foreign key constraints?

Return Value

bool

boolean supportsSchemas()

Whether the platform supports database schemas.

Return Value

boolean

bool canEmulateSchemas()

Can this platform emulate schemas?

Platforms that either support or emulate schemas don't automatically filter a schema for the namespaced elements in {@link AbstractManager#createSchema}.

Return Value

bool

bool supportsCreateDropDatabase()

Some databases don't allow to create and drop databases at all or only with certain tools.

Return Value

bool

boolean supportsGettingAffectedRows()

Whether the platform supports getting the affected rows of a recent update/delete type query.

Return Value

boolean

bool supportsInlineColumnComments()

Does this plaform support to add inline column comments as postfix.

Return Value

bool

bool supportsCommentOnStatement()

Does this platform support the propriortary synatx "COMMENT ON asset"

Return Value

bool

getIdentityColumnNullInsertSQL()

string getDateTimeFormatString()

Gets the format string, as accepted by the date() function, that describes the format of a stored datetime value of this platform.

Return Value

string The format string.

string getDateTimeTzFormatString()

Gets the format string, as accepted by the date() function, that describes the format of a stored datetime with timezone value of this platform.

Return Value

string The format string.

string getDateFormatString()

Gets the format string, as accepted by the date() function, that describes the format of a stored date value of this platform.

Return Value

string The format string.

string getTimeFormatString()

Gets the format string, as accepted by the date() function, that describes the format of a stored time value of this platform.

Return Value

string The format string.

final string modifyLimitQuery(string $query, int $limit, int $offset = null)

Modify limit query

Parameters

string $query
int $limit
int $offset

Return Value

string

protected string doModifyLimitQuery(string $query, int $limit, int $offset = null)

Parameters

string $query
int $limit
int $offset

Return Value

string

bool supportsLimitOffset()

Does the database platform support offsets in modify limit clauses?

Return Value

bool

string getSQLResultCasing(string $column)

Gets the character casing of a column in an SQL result set of this platform.

DB2 returns all column names in SQL result sets in uppercase.

Parameters

string $column The column name for which to get the correct character casing.

Return Value

string The column name in the character casing used in SQL result sets.

string fixSchemaElementName($schemaElementName)

Makes any fixes to a name of a schema element (table, sequence, .

..) that are required by restrictions of the platform, like a maximum length.

Parameters

$schemaElementName

Return Value

string

int getMaxIdentifierLength()

Maximum length of any given databse identifier, like tables or column names.

Return Value

int

string getEmptyIdentityInsertSQL(string $tableName, string $identifierColumnName)

Get the insert sql for an empty insert statement

Parameters

string $tableName
string $identifierColumnName

Return Value

string $sql

string getTruncateTableSQL(string $tableName, bool $cascade = false)

Generate a Truncate Table SQL statement for a given table.

Cascade is not supported on many platforms but would optionally cascade the truncate by following the foreign keys.

Parameters

string $tableName
bool $cascade

Return Value

string

string getDummySelectSQL()

This is for test reasons, many vendors have special requirements for dummy statements.

Return Value

string

string createSavePoint(string $savepoint)

Generate SQL to create a new savepoint

Parameters

string $savepoint

Return Value

string

string releaseSavePoint(string $savepoint)

Generate SQL to release a savepoint

Parameters

string $savepoint

Return Value

string

string rollbackSavePoint(string $savepoint)

Generate SQL to rollback a savepoint

Parameters

string $savepoint

Return Value

string

final KeywordList getReservedKeywordsList()

Return the keyword list instance of this platform.

Throws exception if no keyword list is specified.

Return Value

KeywordList

Exceptions

DBALException

protected string getReservedKeywordsClass()

The class name of the reserved keywords list.

Return Value

string