class DB2Platform extends AbstractPlatform (View source)

Constants

CREATE_INDEXES

CREATE_FOREIGNKEYS

DATE_INTERVAL_UNIT_SECOND

DATE_INTERVAL_UNIT_MINUTE

DATE_INTERVAL_UNIT_HOUR

DATE_INTERVAL_UNIT_DAY

DATE_INTERVAL_UNIT_WEEK

DATE_INTERVAL_UNIT_MONTH

DATE_INTERVAL_UNIT_QUARTER

DATE_INTERVAL_UNIT_YEAR

TRIM_UNSPECIFIED

TRIM_LEADING

TRIM_TRAILING

TRIM_BOTH

Properties

protected array|null $doctrineTypeMapping from AbstractPlatform
protected array|null $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
protected KeywordList $_keywords Holds the KeywordList instance for the current platform. 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)

Returns the SQL snippet that declares a boolean column.

string
getIntegerTypeDeclarationSQL(array $columnDef)

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

string
getBigIntTypeDeclarationSQL(array $columnDef)

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

string
getSmallIntTypeDeclarationSQL(array $columnDef)

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

string
_getCommonIntegerTypeDeclarationSQL(array $columnDef)

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

void
initializeDoctrineTypeMappings()

Lazy load Doctrine Type Mappings.

string
getVarcharTypeDeclarationSQL(array $field)

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

string
getBinaryTypeDeclarationSQL(array $field)

Returns the SQL snippet used to declare a BINARY/VARBINARY column type.

string
getGuidTypeDeclarationSQL(array $field)

Returns the SQL snippet to declare a GUID/UUID field.

string
getJsonTypeDeclarationSQL(array $field)

Returns the SQL snippet to declare a JSON field.

string
getVarcharTypeDeclarationSQLSnippet(int $length, bool $fixed)

No description

string
getBinaryTypeDeclarationSQLSnippet(int $length, bool $fixed)

Returns the SQL snippet used to declare a BINARY/VARBINARY column type.

string
getClobTypeDeclarationSQL(array $field)

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

string
getBlobTypeDeclarationSQL(array $field)

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

string
getName()

Gets the name of the platform.

registerDoctrineTypeMapping(string $dbType, string $doctrineType)

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

string
getDoctrineTypeMapping(string $dbType)

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

bool
hasDoctrineTypeMappingFor(string $dbType)

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

void
initializeCommentedDoctrineTypes()

Initializes 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(string|Type $doctrineType)

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

string
getDoctrineTypeComment(Type $doctrineType)

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

string
getColumnComment(Column $column)

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

getCharMaxLength()

Gets the maximum length of a char field.

int
getVarcharMaxLength()

Gets the maximum length of a varchar field.

int
getVarcharDefaultLength()

Gets the default length of a varchar field.

int
getBinaryMaxLength()

Gets the maximum length of a binary field.

int
getBinaryDefaultLength()

Gets the default length of a binary field.

array
getWildcards()

Gets all SQL wildcard characters of the platform.

string
getRegexpExpression()

Returns the regular expression operator.

string
getGuidExpression()

Returns the global unique identifier expression.

string
getAvgExpression(string $column)

Returns the SQL snippet to get the average value of a column.

string
getCountExpression(string|integer $column)

Returns the SQL snippet to get the number of rows (without a NULL value) of a column.

string
getMaxExpression(string $column)

Returns the SQL snippet to get the highest value of a column.

string
getMinExpression(string $column)

Returns the SQL snippet to get the lowest value of a column.

string
getSumExpression(string $column)

Returns the SQL snippet to get the total sum of a column.

string
getMd5Expression(string $column)

Returns the SQL snippet to get the md5 sum of a field.

string
getLengthExpression(string $column)

Returns the SQL snippet to get the length of a text field.

string
getSqrtExpression(string $column)

Returns the SQL snippet to get the squared value of a column.

string
getRoundExpression(string $column, int $decimals = 0)

Returns the SQL snippet to round a numeric field to the number of decimals specified.

string
getModExpression(string $expression1, string $expression2)

Returns the SQL snippet to get the remainder of the division operation $expression1 / $expression2.

string
getTrimExpression(string $str, int $mode = TrimMode::UNSPECIFIED, string|bool $char = false)

Returns the SQL snippet to trim a string.

string
getRtrimExpression(string $str)

Returns the SQL snippet to trim trailing space characters from the expression.

string
getLtrimExpression(string $str)

Returns the SQL snippet to trim leading space characters from the expression.

string
getUpperExpression(string $str)

Returns the SQL snippet to change all characters from the expression to uppercase, according to the current character set mapping.

string
getLowerExpression(string $str)

Returns the SQL snippet to change all characters from the expression to lowercase, according to the current character set mapping.

string
getLocateExpression(string $str, string $substr, int|bool $startPos = false)

Returns the SQL snippet to get the position of the first occurrence of substring $substr in string $str.

string
getNowExpression()

Returns the SQL snippet to get the current system date.

string
getSubstringExpression(string $value, int $from, int|null $length = null)

Returns a SQL snippet to get a substring inside an SQL statement.

string
getConcatExpression()

Returns a SQL snippet to concatenate the given expressions.

string
getNotExpression(string $expression)

Returns the SQL for a logical not.

string
getIsNullExpression(string $expression)

Returns the SQL that checks if an expression is null.

string
getIsNotNullExpression(string $expression)

Returns the SQL that checks if an expression is not null.

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

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

string
getAcosExpression(string $value)

Returns the SQL to get the arccosine of a value.

string
getSinExpression(string $value)

Returns the SQL to get the sine of a value.

string
getPiExpression()

Returns the SQL to get the PI value.

string
getCosExpression(string $value)

Returns the SQL to get the cosine of a value.

string
getDateDiffExpression(string $date1, string $date2)

Returns the SQL to calculate the difference in days between the two passed dates.

string
getDateAddSecondsExpression(string $date, int $seconds)

Returns the SQL to add the number of given seconds to a date.

string
getDateSubSecondsExpression(string $date, int $seconds)

Returns the SQL to subtract the number of given seconds from a date.

string
getDateAddMinutesExpression(string $date, int $minutes)

Returns the SQL to add the number of given minutes to a date.

string
getDateSubMinutesExpression(string $date, int $minutes)

Returns the SQL to subtract the number of given minutes from a date.

string
getDateAddHourExpression(string $date, int $hours)

Returns the SQL to add the number of given hours to a date.

string
getDateSubHourExpression(string $date, int $hours)

Returns the SQL to subtract the number of given hours to a date.

string
getDateAddDaysExpression(string $date, int $days)

Returns the SQL to add the number of given days to a date.

string
getDateSubDaysExpression(string $date, int $days)

Returns the SQL to subtract the number of given days to a date.

string
getDateAddWeeksExpression(string $date, int $weeks)

Returns the SQL to add the number of given weeks to a date.

string
getDateSubWeeksExpression(string $date, int $weeks)

Returns the SQL to subtract the number of given weeks from a date.

string
getDateAddMonthExpression(string $date, int $months)

Returns the SQL to add the number of given months to a date.

string
getDateSubMonthExpression(string $date, int $months)

Returns the SQL to subtract the number of given months to a date.

string
getDateAddQuartersExpression(string $date, int $quarters)

Returns the SQL to add the number of given quarters to a date.

string
getDateSubQuartersExpression(string $date, int $quarters)

Returns the SQL to subtract the number of given quarters from a date.

string
getDateAddYearsExpression(string $date, int $years)

Returns the SQL to add the number of given years to a date.

string
getDateSubYearsExpression(string $date, int $years)

Returns the SQL to subtract the number of given years from a date.

string
getDateArithmeticIntervalExpression(string $date, string $operator, int $interval, string $unit)

Returns the SQL for a date arithmetic expression.

string
getBitAndComparisonExpression(string $value1, string $value2)

Returns the SQL bit AND comparison expression.

string
getBitOrComparisonExpression(string $value1, string $value2)

Returns the SQL bit OR comparison expression.

string
getForUpdateSQL()

Returns the FOR UPDATE expression.

string
appendLockHint(string $fromClause, int|null $lockMode)

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

string
getReadLockSQL()

Returns the SQL snippet to append to any SELECT statement which locks rows in shared read lock.

string
getWriteLockSQL()

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

string
getDropDatabaseSQL(string $database)

Returns the SQL snippet to drop an existing database.

string
getDropTableSQL(Table|string $table)

Returns the SQL snippet to drop an existing table.

string
getDropTemporaryTableSQL(Table|string $table)

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

string
getDropIndexSQL(Index|string $index, Table|string $table = null)

Returns the SQL to drop an index from a table.

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

Returns the SQL to drop a constraint.

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

Returns the SQL to drop a foreign key.

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

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

string
getCommentOnColumnSQL(string $tableName, string $columnName, string $comment)

No description

string
getInlineColumnCommentSQL(string $comment)

Returns the SQL to create inline comment on a column.

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

Returns the SQL used to create a table.

string
string
getCreateSequenceSQL(Sequence $sequence)

Returns the SQL to create a sequence on this platform.

string
getAlterSequenceSQL(Sequence $sequence)

Returns the SQL to change a sequence on this platform.

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

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

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

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

string
getPartialIndexSQL(Index $index)

Adds condition for partial index.

string
getCreateIndexSQLFlags(Index $index)

Adds additional flags for index generation.

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

Returns the SQL to create an unnamed primary key constraint.

string
getCreateSchemaSQL(string $schemaName)

Returns the SQL to create a named schema.

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 separated by dot and quotes them independently.

string
quoteSingleIdentifier(string $str)

Quotes a single identifier (no dot chain separation).

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

Returns the SQL to create a new foreign key.

array
getAlterTableSQL(TableDiff $diff)

Gets the SQL statements for altering an existing table.

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

No description

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

No description

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

No description

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

No description

bool
onSchemaAlterTable(TableDiff $diff, array $sql)

No description

array
array
getRenameIndexSQL(string $oldIndexName, Index $index, string $tableName)

Returns the SQL for renaming an index on a table.

array
_getAlterTableIndexForeignKeySQL(TableDiff $diff)

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

string
getColumnDeclarationListSQL(array $fields)

Gets declaration of a number of fields in bulk.

string
getColumnDeclarationSQL(string $name, array $field)

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

string
getDecimalTypeDeclarationSQL(array $columnDef)

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

string
getDefaultValueDeclarationSQL(array $field)

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

string
getCheckDeclarationSQL(array $definition)

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

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

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

string
getCustomTypeDeclarationSQL(array $columnDef)

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

string
getIndexFieldDeclarationListSQL(array $fields)

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

string
getTemporaryTableSQL()

Returns the required SQL string that fits between CREATE .

string
getTemporaryTableName(string $tableName)

Some vendors require temporary table names to be qualified specially.

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)

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

string
getForeignKeyReferentialActionSQL(string $action)

Returns the given referential action in uppercase if valid, otherwise throws an exception.

string
getForeignKeyBaseDeclarationSQL(ForeignKeyConstraint $foreignKey)

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

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

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

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

bool
prefersSequences()

Whether the platform prefers sequences for ID generation.

bool
prefersIdentityColumns()

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

mixed
convertBooleans(mixed $item)

Some platforms need the boolean values to be converted.

bool|null
convertFromBoolean(mixed $item)

Some platforms have boolean literals that needs to be correctly converted

mixed
convertBooleansToDatabaseValue(mixed $item)

This method should handle the prepared statements case. When there is no distinction, it's OK to use the same method.

string
getCurrentDateSQL()

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

string
getCurrentTimeSQL()

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

string
getCurrentTimestampSQL()

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

string
_getTransactionIsolationLevelSQL(int $level)

Returns the SQL for a given transaction isolation level Connection constant.

string
getListDatabasesSQL()

No description

string
getListNamespacesSQL()

Returns the SQL statement for retrieving the namespaces defined in the database.

string
getListSequencesSQL(string $database)

No description

string
getListTableConstraintsSQL(string $table)

No description

string
getListTableColumnsSQL(string $table, string|null $database = null)

This code fragment is originally from the Zend_Db_Adapter_Db2 class, but has been edited.

string
getListTablesSQL()

No description

string
getListUsersSQL()

No description

string
getListViewsSQL(string $database)

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

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

Returns the list of indexes for the current database.

string
getListTableForeignKeysSQL(string $table)

No description

string
getCreateViewSQL(string $name, string $sql)

No description

string
getDropViewSQL(string $name)

No description

string
getDropSequenceSQL(Sequence|string $sequence)

Returns the SQL snippet to drop an existing sequence.

string
getSequenceNextValSQL(string $sequenceName)

No description

string
getCreateDatabaseSQL(string $database)

Returns the SQL to create a new database.

string
getSetTransactionIsolationSQL(int $level)

Returns the SQL to set the transaction isolation level.

string
getDateTimeTypeDeclarationSQL(array $fieldDeclaration)

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

string
getDateTimeTzTypeDeclarationSQL(array $fieldDeclaration)

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

string
getDateTypeDeclarationSQL(array $fieldDeclaration)

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

string
getTimeTypeDeclarationSQL(array $fieldDeclaration)

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

string
getFloatDeclarationSQL(array $fieldDeclaration)

No description

int
getDefaultTransactionIsolationLevel()

Gets the default transaction isolation level of the platform.

bool
supportsSequences()

Whether the platform supports sequences.

bool
supportsIdentityColumns()

Whether the platform supports identity columns.

bool
usesSequenceEmulatedIdentityColumns()

Whether the platform emulates identity columns through sequences.

string
getIdentitySequenceName(string $tableName, string $columnName)

Returns the name of the sequence for a particular identity column in a particular table.

bool
supportsIndexes()

Whether the platform supports indexes.

bool
supportsPartialIndexes()

Whether the platform supports partial indexes.

bool
supportsAlterTable()

Whether the platform supports altering tables.

bool
supportsTransactions()

Whether the platform supports transactions.

bool
supportsSavepoints()

Whether the platform supports savepoints.

bool
supportsReleaseSavepoints()

Whether the platform supports releasing savepoints.

bool
supportsPrimaryConstraints()

Whether the platform supports primary key constraints.

bool
supportsForeignKeyConstraints()

Whether the platform supports foreign key constraints.

bool
supportsForeignKeyOnUpdate()

Whether this platform supports onUpdate in foreign key constraints.

bool
supportsSchemas()

Whether the platform supports database schemas.

bool
canEmulateSchemas()

Whether this platform can emulate schemas.

string
getDefaultSchemaName()

Returns the default schema name.

bool
supportsCreateDropDatabase()

Whether this platform supports create database.

bool
supportsGettingAffectedRows()

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

bool
supportsInlineColumnComments()

Whether this platform support to add inline column comments as postfix.

bool
supportsCommentOnStatement()

Whether this platform support the proprietary syntax "COMMENT ON asset".

bool
hasNativeGuidType()

Does this platform have native guid type.

bool
hasNativeJsonType()

Does this platform have native JSON type.

getIdentityColumnNullInsertSQL() deprecated

No description

bool
supportsViews()

Whether this platform supports views.

bool
supportsColumnCollation()

Does this platform support column collation?

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|null $limit, int|null $offset = null)

Adds an driver-specific LIMIT clause to the query.

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

Adds an driver-specific LIMIT clause to the query.

bool
supportsLimitOffset()

Whether 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(string $schemaElementName)

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

int
getMaxIdentifierLength()

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

string
getEmptyIdentityInsertSQL(string $tableName, string $identifierColumnName)

Returns the insert SQL for an empty insert statement.

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

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

Returns the SQL to create a new savepoint.

string
releaseSavePoint(string $savepoint)

Returns the SQL to release a savepoint.

string
rollbackSavePoint(string $savepoint)

Returns the SQL to rollback a savepoint.

getReservedKeywordsList()

Returns the keyword list instance of this platform.

string
getReservedKeywordsClass()

Returns the class name of the reserved keywords list.

string
quoteStringLiteral(string $str)

Quotes a literal string.

string
getStringLiteralQuoteCharacter()

Gets the character used for string literal quoting.

escapeStringForLike(string $inputString, string $escapeChar)

Escapes metacharacters in a string intended to be used with a LIKE operator.

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)

Returns the SQL snippet that declares a boolean column.

Parameters

array $columnDef

Return Value

string

string getIntegerTypeDeclarationSQL(array $columnDef)

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

Parameters

array $columnDef

Return Value

string

string getBigIntTypeDeclarationSQL(array $columnDef)

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

Parameters

array $columnDef

Return Value

string

string getSmallIntTypeDeclarationSQL(array $columnDef)

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

Parameters

array $columnDef

Return Value

string

protected string _getCommonIntegerTypeDeclarationSQL(array $columnDef)

Returns 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

string getVarcharTypeDeclarationSQL(array $field)

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

Parameters

array $field

Return Value

string

string getBinaryTypeDeclarationSQL(array $field)

Returns the SQL snippet used to declare a BINARY/VARBINARY column type.

Parameters

array $field The column definition.

Return Value

string

string getGuidTypeDeclarationSQL(array $field)

Returns the SQL snippet to declare a GUID/UUID field.

By default this maps directly to a CHAR(36) and only maps to more special datatypes when the underlying databases support this datatype.

Parameters

array $field

Return Value

string

string getJsonTypeDeclarationSQL(array $field)

Returns the SQL snippet to declare a JSON field.

By default this maps directly to a CLOB and only maps to more special datatypes when the underlying databases support this datatype.

Parameters

array $field

Return Value

string

protected string getVarcharTypeDeclarationSQLSnippet(int $length, bool $fixed)

Parameters

int $length
bool $fixed

Return Value

string

Exceptions

DBALException If not supported on this platform.

protected string getBinaryTypeDeclarationSQLSnippet(int $length, bool $fixed)

Returns the SQL snippet used to declare a BINARY/VARBINARY column type.

Parameters

int $length The length of the column.
bool $fixed Whether the column length is fixed.

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getClobTypeDeclarationSQL(array $field)

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

Parameters

array $field

Return Value

string

string getBlobTypeDeclarationSQL(array $field)

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

Parameters

array $field

Return Value

string

string getName()

Gets the name of the platform.

Return Value

string

registerDoctrineTypeMapping(string $dbType, string $doctrineType)

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

Parameters

string $dbType
string $doctrineType

Exceptions

DBALException If the type is not found.

string getDoctrineTypeMapping(string $dbType)

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

Parameters

string $dbType

Return Value

string

Exceptions

DBALException

bool hasDoctrineTypeMappingFor(string $dbType)

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

Parameters

string $dbType

Return Value

bool

protected void initializeCommentedDoctrineTypes()

Initializes 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(string|Type $doctrineType)

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

Parameters

string|Type $doctrineType

Return Value

void

string getDoctrineTypeComment(Type $doctrineType)

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

Gets 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

getCharMaxLength()

Gets the maximum length of a char field.

int getVarcharMaxLength()

Gets the maximum length of a varchar field.

Return Value

int

int getVarcharDefaultLength()

Gets the default length of a varchar field.

Return Value

int

int getBinaryMaxLength()

Gets the maximum length of a binary field.

Return Value

int

int getBinaryDefaultLength()

Gets the default length of a binary field.

Return Value

int

array getWildcards()

Gets all SQL wildcard characters of the platform.

Return Value

array

string getRegexpExpression()

Returns the regular expression operator.

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getGuidExpression()

Returns the global unique identifier expression.

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getAvgExpression(string $column)

Returns the SQL snippet to get 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 SQL snippet to get 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 SQL snippet to get 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 SQL snippet to get the lowest value of a column.

Parameters

string $column The column to use.

Return Value

string Generated SQL including a MIN aggregate function.

string getSumExpression(string $column)

Returns the SQL snippet to get the total sum of a column.

Parameters

string $column The column to use.

Return Value

string Generated SQL including a SUM aggregate function.

string getMd5Expression(string $column)

Returns the SQL snippet to get the md5 sum of a field.

Note: Not SQL92, but common functionality.

Parameters

string $column

Return Value

string

string getLengthExpression(string $column)

Returns the SQL snippet to get the length of a text field.

Parameters

string $column

Return Value

string

string getSqrtExpression(string $column)

Returns the SQL snippet to get the squared value of a column.

Parameters

string $column The column to use.

Return Value

string Generated SQL including an SQRT aggregate function.

string getRoundExpression(string $column, int $decimals = 0)

Returns the SQL snippet to round a numeric field to the number of decimals specified.

Parameters

string $column
int $decimals

Return Value

string

string getModExpression(string $expression1, string $expression2)

Returns the SQL snippet to get the remainder of the division operation $expression1 / $expression2.

Parameters

string $expression1
string $expression2

Return Value

string

string getTrimExpression(string $str, int $mode = TrimMode::UNSPECIFIED, string|bool $char = false)

Returns the SQL snippet to trim a string.

Parameters

string $str The expression to apply the trim to.
int $mode The position of the trim (leading/trailing/both).
string|bool $char The char to trim, has to be quoted already. Defaults to space.

Return Value

string

string getRtrimExpression(string $str)

Returns the SQL snippet to trim trailing space characters from the expression.

Parameters

string $str Literal string or column name.

Return Value

string

string getLtrimExpression(string $str)

Returns the SQL snippet to trim leading space characters from the expression.

Parameters

string $str Literal string or column name.

Return Value

string

string getUpperExpression(string $str)

Returns the SQL snippet to change all characters from the expression to uppercase, according to the current character set mapping.

Parameters

string $str Literal string or column name.

Return Value

string

string getLowerExpression(string $str)

Returns the SQL snippet to change all characters from the expression to lowercase, according to the current character set mapping.

Parameters

string $str Literal string or column name.

Return Value

string

string getLocateExpression(string $str, string $substr, int|bool $startPos = false)

Returns the SQL snippet to get the position of the first occurrence of substring $substr in string $str.

Parameters

string $str Literal string.
string $substr Literal string to find.
int|bool $startPos Position to start at, beginning of string by default.

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getNowExpression()

Returns the SQL snippet to get the current system date.

Return Value

string

string getSubstringExpression(string $value, int $from, int|null $length = null)

Returns a SQL snippet 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.
int $from Where to start the substring portion.
int|null $length The substring portion length.

Return Value

string

string getConcatExpression()

Returns a SQL snippet to concatenate the given expressions.

Accepts an arbitrary number of string parameters. Each parameter must contain an expression.

Return Value

string

string getNotExpression(string $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

string $expression

Return Value

string The logical expression.

string getIsNullExpression(string $expression)

Returns the SQL that checks if an expression is null.

Parameters

string $expression The expression that should be compared to null.

Return Value

string The logical expression.

string getIsNotNullExpression(string $expression)

Returns the SQL that checks if an expression is not null.

Parameters

string $expression The expression that should be compared to null.

Return Value

string The logical expression.

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

Returns the 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 The logical expression.

string getAcosExpression(string $value)

Returns the SQL to get the arccosine of a value.

Parameters

string $value

Return Value

string

string getSinExpression(string $value)

Returns the SQL to get the sine of a value.

Parameters

string $value

Return Value

string

string getPiExpression()

Returns the SQL to get the PI value.

Return Value

string

string getCosExpression(string $value)

Returns the SQL to get the cosine of a value.

Parameters

string $value

Return Value

string

string getDateDiffExpression(string $date1, string $date2)

Returns the SQL to calculate the difference in days between the two passed dates.

Computes diff = date1 - date2.

Parameters

string $date1
string $date2

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getDateAddSecondsExpression(string $date, int $seconds)

Returns the SQL to add the number of given seconds to a date.

Parameters

string $date
int $seconds

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getDateSubSecondsExpression(string $date, int $seconds)

Returns the SQL to subtract the number of given seconds from a date.

Parameters

string $date
int $seconds

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getDateAddMinutesExpression(string $date, int $minutes)

Returns the SQL to add the number of given minutes to a date.

Parameters

string $date
int $minutes

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getDateSubMinutesExpression(string $date, int $minutes)

Returns the SQL to subtract the number of given minutes from a date.

Parameters

string $date
int $minutes

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getDateAddHourExpression(string $date, int $hours)

Returns the SQL to add the number of given hours to a date.

Parameters

string $date
int $hours

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getDateSubHourExpression(string $date, int $hours)

Returns the SQL to subtract the number of given hours to a date.

Parameters

string $date
int $hours

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getDateAddDaysExpression(string $date, int $days)

Returns the SQL to add the number of given days to a date.

Parameters

string $date
int $days

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getDateSubDaysExpression(string $date, int $days)

Returns the SQL to subtract the number of given days to a date.

Parameters

string $date
int $days

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getDateAddWeeksExpression(string $date, int $weeks)

Returns the SQL to add the number of given weeks to a date.

Parameters

string $date
int $weeks

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getDateSubWeeksExpression(string $date, int $weeks)

Returns the SQL to subtract the number of given weeks from a date.

Parameters

string $date
int $weeks

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getDateAddMonthExpression(string $date, int $months)

Returns the SQL to add the number of given months to a date.

Parameters

string $date
int $months

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getDateSubMonthExpression(string $date, int $months)

Returns the SQL to subtract the number of given months to a date.

Parameters

string $date
int $months

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getDateAddQuartersExpression(string $date, int $quarters)

Returns the SQL to add the number of given quarters to a date.

Parameters

string $date
int $quarters

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getDateSubQuartersExpression(string $date, int $quarters)

Returns the SQL to subtract the number of given quarters from a date.

Parameters

string $date
int $quarters

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getDateAddYearsExpression(string $date, int $years)

Returns the SQL to add the number of given years to a date.

Parameters

string $date
int $years

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getDateSubYearsExpression(string $date, int $years)

Returns the SQL to subtract the number of given years from a date.

Parameters

string $date
int $years

Return Value

string

Exceptions

DBALException If not supported on this platform.

protected string getDateArithmeticIntervalExpression(string $date, string $operator, int $interval, string $unit)

Returns the SQL for a date arithmetic expression.

Parameters

string $date The column or literal representing a date to perform the arithmetic operation on.
string $operator The arithmetic operator (+ or -).
int $interval The interval that shall be calculated into the date.
string $unit The unit of the interval that shall be calculated into the date. One of the DATE_INTERVAL_UNIT_* constants.

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getBitAndComparisonExpression(string $value1, string $value2)

Returns the SQL bit AND comparison expression.

Parameters

string $value1
string $value2

Return Value

string

string getBitOrComparisonExpression(string $value1, string $value2)

Returns the SQL bit OR comparison expression.

Parameters

string $value1
string $value2

Return Value

string

string getForUpdateSQL()

Returns the FOR UPDATE expression.

Return Value

string

string appendLockHint(string $fromClause, int|null $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 The FROM clause to append the hint for the given lock mode to.
int|null $lockMode One of the Doctrine\DBAL\LockMode::* constants. If null is given, nothing will be appended to the FROM clause.

Return Value

string

string getReadLockSQL()

Returns the SQL snippet to append to any SELECT statement which locks rows in shared read lock.

This defaults to the ANSI 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()

Returns 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 ANSI SQL standard.

Return Value

string

string getDropDatabaseSQL(string $database)

Returns the SQL snippet to drop an existing database.

Parameters

string $database The name of the database that should be dropped.

Return Value

string

string getDropTableSQL(Table|string $table)

Returns the SQL snippet to drop an existing table.

Parameters

Table|string $table

Return Value

string

Exceptions

InvalidArgumentException

string getDropTemporaryTableSQL(Table|string $table)

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

Parameters

Table|string $table

Return Value

string

string getDropIndexSQL(Index|string $index, Table|string $table = null)

Returns the SQL to drop an index from a table.

Parameters

Index|string $index
Table|string $table

Return Value

string

Exceptions

InvalidArgumentException

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

Returns the SQL to drop a constraint.

Parameters

Constraint|string $constraint
Table|string $table

Return Value

string

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

Returns the SQL to drop a foreign key.

Parameters

ForeignKeyConstraint|string $foreignKey
Table|string $table

Return Value

string

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

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

Parameters

Table $table
int $createFlags

Return Value

array The sequence of SQL statements.

Exceptions

DBALException
InvalidArgumentException

string getCommentOnColumnSQL(string $tableName, string $columnName, string $comment)

Parameters

string $tableName
string $columnName
string $comment

Return Value

string

string getInlineColumnCommentSQL(string $comment)

Returns the SQL to create inline comment on a column.

Parameters

string $comment

Return Value

string

Exceptions

DBALException If not supported on this platform.

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

Returns the SQL used to create a table.

Parameters

string $tableName
array $columns
array $options

Return Value

array

string getCreateTemporaryTableSnippetSQL()

Return Value

string

string getCreateSequenceSQL(Sequence $sequence)

Returns the SQL to create a sequence on this platform.

Parameters

Sequence $sequence

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getAlterSequenceSQL(Sequence $sequence)

Returns the SQL to change a sequence on this platform.

Parameters

Sequence $sequence

Return Value

string

Exceptions

DBALException If not supported on this platform.

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

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

Parameters

Constraint $constraint
Table|string $table

Return Value

string

Exceptions

InvalidArgumentException

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

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

Parameters

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

Return Value

string

Exceptions

InvalidArgumentException

protected string getPartialIndexSQL(Index $index)

Adds condition for partial index.

Parameters

Index $index

Return Value

string

protected string getCreateIndexSQLFlags(Index $index)

Adds additional flags for index generation.

Parameters

Index $index

Return Value

string

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

Returns the SQL to create an unnamed primary key constraint.

Parameters

Index $index
Table|string $table

Return Value

string

string getCreateSchemaSQL(string $schemaName)

Returns the SQL to create a named schema.

Parameters

string $schemaName

Return Value

string

Exceptions

DBALException If not supported on this platform.

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 separated 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 The identifier name to be quoted.

Return Value

string The quoted identifier string.

string quoteSingleIdentifier(string $str)

Quotes a single identifier (no dot chain separation).

Parameters

string $str The identifier name to be quoted.

Return Value

string The quoted identifier string.

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

Returns the SQL to create a new foreign key.

Parameters

ForeignKeyConstraint $foreignKey The foreign key constraint.
Table|string $table The name of the table on which the foreign key is to be created.

Return Value

string

array getAlterTableSQL(TableDiff $diff)

Gets the SQL statements for altering an existing table.

This method returns an array of SQL statements, since some platforms need several statements.

Parameters

TableDiff $diff

Return Value

array

Exceptions

DBALException If not supported on this platform.

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

Parameters

Column $column
TableDiff $diff
array $columnSql

Return Value

bool

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

Parameters

Column $column
TableDiff $diff
array $columnSql

Return Value

bool

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

Parameters

ColumnDiff $columnDiff
TableDiff $diff
array $columnSql

Return Value

bool

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

Parameters

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

Return Value

bool

protected bool onSchemaAlterTable(TableDiff $diff, array $sql)

Parameters

TableDiff $diff
array $sql

Return Value

bool

protected array getPreAlterTableIndexForeignKeySQL(TableDiff $diff)

Parameters

TableDiff $diff

Return Value

array

protected array getPostAlterTableIndexForeignKeySQL(TableDiff $diff)

Parameters

TableDiff $diff

Return Value

array

protected array getRenameIndexSQL(string $oldIndexName, Index $index, string $tableName)

Returns the SQL for renaming an index on a table.

Parameters

string $oldIndexName The name of the index to rename from.
Index $index The definition of the index to rename to.
string $tableName The table to rename the given index on.

Return Value

array The sequence of SQL statements for renaming the given index.

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)

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

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

Parameters

string $name The name the field to be declared.
array $field An 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)

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

Parameters

array $columnDef

Return Value

string

string getDefaultValueDeclarationSQL(array $field)

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

Parameters

array $field The field definition array.

Return Value

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

string getCheckDeclarationSQL(array $definition)

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

Parameters

array $definition The check definition.

Return Value

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

string getUniqueConstraintDeclarationSQL(string $name, Index $index)

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

Parameters

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

Return Value

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

Exceptions

InvalidArgumentException

string getIndexDeclarationSQL(string $name, Index $index)

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

Parameters

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

Return Value

string DBMS specific SQL code portion needed to set an index.

Exceptions

InvalidArgumentException

string getCustomTypeDeclarationSQL(array $columnDef)

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

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

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

Some vendors require temporary table names to be qualified specially.

Parameters

string $tableName

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)

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

..

Parameters

ForeignKeyConstraint $foreignKey The foreign key definition.

Return Value

string

string getForeignKeyReferentialActionSQL(string $action)

Returns the given referential action in uppercase if valid, otherwise throws an exception.

Parameters

string $action The foreign key referential action.

Return Value

string

Exceptions

InvalidArgumentException if unknown referential action given

string getForeignKeyBaseDeclarationSQL(ForeignKeyConstraint $foreignKey)

Obtains 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

Exceptions

InvalidArgumentException

string getUniqueFieldDeclarationSQL()

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

Obtains 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 The 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)

Obtains 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 The name of the collation.

Return Value

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

bool prefersSequences()

Whether the platform prefers sequences for ID generation.

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

Return Value

bool

bool 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

bool

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

Note: if the input is not a boolean the original input might be returned.

There are two contexts when converting booleans: Literals and Prepared Statements. This method should handle the literal case

Parameters

mixed $item A boolean or an array of them.

Return Value

mixed A boolean database value or an array of them.

bool|null convertFromBoolean(mixed $item)

Some platforms have boolean literals that needs to be correctly converted

The default conversion tries to convert value into bool "(bool)$item"

Parameters

mixed $item

Return Value

bool|null

mixed convertBooleansToDatabaseValue(mixed $item)

This method should handle the prepared statements case. When there is no distinction, it's OK to use the same method.

Note: if the input is not a boolean the original input might be returned.

Parameters

mixed $item A boolean or an array of them.

Return Value

mixed A boolean database value or an array of them.

string getCurrentDateSQL()

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

Return Value

string

string getCurrentTimeSQL()

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

Return Value

string

string getCurrentTimestampSQL()

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

Return Value

string

protected string _getTransactionIsolationLevelSQL(int $level)

Returns the SQL for a given transaction isolation level Connection constant.

Parameters

int $level

Return Value

string

Exceptions

InvalidArgumentException

string getListDatabasesSQL()

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getListNamespacesSQL()

Returns the SQL statement for retrieving the namespaces defined in the database.

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getListSequencesSQL(string $database)

Parameters

string $database

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getListTableConstraintsSQL(string $table)

Parameters

string $table

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getListTableColumnsSQL(string $table, string|null $database = null)

This code fragment is originally from the Zend_Db_Adapter_Db2 class, but has been edited.

Parameters

string $table
string|null $database

Return Value

string

string getListTablesSQL()

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getListUsersSQL()

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getListViewsSQL(string $database)

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

Parameters

string $database

Return Value

string

Exceptions

DBALException If not supported on this platform.

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

Returns 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

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getListTableForeignKeysSQL(string $table)

Parameters

string $table

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getCreateViewSQL(string $name, string $sql)

Parameters

string $name
string $sql

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getDropViewSQL(string $name)

Parameters

string $name

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getDropSequenceSQL(Sequence|string $sequence)

Returns the SQL snippet to drop an existing sequence.

Parameters

Sequence|string $sequence

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getSequenceNextValSQL(string $sequenceName)

Parameters

string $sequenceName

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getCreateDatabaseSQL(string $database)

Returns the SQL to create a new database.

Parameters

string $database The name of the database that should be created.

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getSetTransactionIsolationSQL(int $level)

Returns the SQL to set the transaction isolation level.

Parameters

int $level

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getDateTimeTypeDeclarationSQL(array $fieldDeclaration)

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

Parameters

array $fieldDeclaration

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getDateTimeTzTypeDeclarationSQL(array $fieldDeclaration)

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

Parameters

array $fieldDeclaration

Return Value

string

string getDateTypeDeclarationSQL(array $fieldDeclaration)

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

Parameters

array $fieldDeclaration

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getTimeTypeDeclarationSQL(array $fieldDeclaration)

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

Parameters

array $fieldDeclaration

Return Value

string

Exceptions

DBALException If not supported on this platform.

string getFloatDeclarationSQL(array $fieldDeclaration)

Parameters

array $fieldDeclaration

Return Value

string

int getDefaultTransactionIsolationLevel()

Gets the default transaction isolation level of the platform.

Return Value

int The default isolation level.

See also

TransactionIsolationLevel

bool supportsSequences()

Whether the platform supports sequences.

Return Value

bool

bool supportsIdentityColumns()

Whether the platform supports identity columns.

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

Return Value

bool

bool usesSequenceEmulatedIdentityColumns()

Whether the platform emulates identity columns through sequences.

Some platforms that do not support identity columns natively but support sequences can emulate identity columns by using sequences.

Return Value

bool

string getIdentitySequenceName(string $tableName, string $columnName)

Returns the name of the sequence for a particular identity column in a particular table.

Parameters

string $tableName The name of the table to return the sequence name for.
string $columnName The name of the identity column in the table to return the sequence name for.

Return Value

string

Exceptions

DBALException If not supported on this platform.

See also

usesSequenceEmulatedIdentityColumns

bool supportsIndexes()

Whether the platform supports indexes.

Return Value

bool

bool supportsPartialIndexes()

Whether the platform supports partial indexes.

Return Value

bool

bool supportsAlterTable()

Whether the platform supports altering tables.

Return Value

bool

bool supportsTransactions()

Whether the platform supports transactions.

Return Value

bool

bool supportsSavepoints()

Whether the platform supports savepoints.

Return Value

bool

bool supportsReleaseSavepoints()

Whether the platform supports releasing savepoints.

Return Value

bool

bool supportsPrimaryConstraints()

Whether the platform supports primary key constraints.

Return Value

bool

bool supportsForeignKeyConstraints()

Whether the platform supports foreign key constraints.

Return Value

bool

bool supportsForeignKeyOnUpdate()

Whether this platform supports onUpdate in foreign key constraints.

Return Value

bool

bool supportsSchemas()

Whether the platform supports database schemas.

Return Value

bool

bool canEmulateSchemas()

Whether this platform can 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

string getDefaultSchemaName()

Returns the default schema name.

Return Value

string

Exceptions

DBALException If not supported on this platform.

bool supportsCreateDropDatabase()

Whether this platform supports create database.

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

Return Value

bool

bool supportsGettingAffectedRows()

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

Return Value

bool

bool supportsInlineColumnComments()

Whether this platform support to add inline column comments as postfix.

Return Value

bool

bool supportsCommentOnStatement()

Whether this platform support the proprietary syntax "COMMENT ON asset".

Return Value

bool

bool hasNativeGuidType()

Does this platform have native guid type.

Return Value

bool

bool hasNativeJsonType()

Does this platform have native JSON type.

Return Value

bool

getIdentityColumnNullInsertSQL() deprecated

deprecated

bool supportsViews()

Whether this platform supports views.

Return Value

bool

bool supportsColumnCollation()

Does this platform support column collation?

Return Value

bool

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|null $limit, int|null $offset = null)

Adds an driver-specific LIMIT clause to the query.

Parameters

string $query
int|null $limit
int|null $offset

Return Value

string

Exceptions

DBALException

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

Adds an driver-specific LIMIT clause to the query.

Parameters

string $query
int|null $limit
int|null $offset

Return Value

string

bool supportsLimitOffset()

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

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(string $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

string $schemaElementName

Return Value

string

int getMaxIdentifierLength()

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

Return Value

int

string getEmptyIdentityInsertSQL(string $tableName, string $identifierColumnName)

Returns the insert SQL for an empty insert statement.

Parameters

string $tableName
string $identifierColumnName

Return Value

string

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

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

Returns the SQL to create a new savepoint.

Parameters

string $savepoint

Return Value

string

string releaseSavePoint(string $savepoint)

Returns the SQL to release a savepoint.

Parameters

string $savepoint

Return Value

string

string rollbackSavePoint(string $savepoint)

Returns the SQL to rollback a savepoint.

Parameters

string $savepoint

Return Value

string

final KeywordList getReservedKeywordsList()

Returns the keyword list instance of this platform.

Return Value

KeywordList

Exceptions

DBALException If no keyword list is specified.

protected string getReservedKeywordsClass()

Returns the class name of the reserved keywords list.

Return Value

string

Exceptions

DBALException If not supported on this platform.

string quoteStringLiteral(string $str)

Quotes a literal string.

This method is NOT meant to fix SQL injections! It is only meant to escape this platform's string literal quote character inside the given literal string.

Parameters

string $str The literal string to be quoted.

Return Value

string The quoted literal string.

string getStringLiteralQuoteCharacter()

Gets the character used for string literal quoting.

Return Value

string

final escapeStringForLike(string $inputString, string $escapeChar)

Escapes metacharacters in a string intended to be used with a LIKE operator.

Parameters

string $inputString a literal, unquoted string
string $escapeChar should be reused by the caller in the LIKE expression.

protected getLikeWildcardCharacters()