abstract class AbstractPlatform (View source)

Base class for all DatabasePlatforms. The DatabasePlatforms are the central point of abstraction of platform-specific behaviors, features and SQL dialects.

They are a passive source of information.

Constants

CREATE_INDEXES

CREATE_FOREIGNKEYS

TRIM_UNSPECIFIED

TRIM_LEADING

TRIM_TRAILING

TRIM_BOTH

Properties

protected array $doctrineTypeMapping
protected array $doctrineTypeComments Contains a list of all columns that should generate parseable column comments for type-detection in reverse engineering scenarios.
protected EventManager $_eventManager
protected KeywordList $_keywords Holds the KeywordList instance for the current platform.

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

string
getVarcharTypeDeclarationSQL(array $field)

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

string
getGuidTypeDeclarationSQL(array $field)

Get the SQL Snippet to create a GUID/UUID field.

string
getVarcharTypeDeclarationSQLSnippet(integer $length, boolean $fixed)

No description

string
getClobTypeDeclarationSQL(array $field)

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

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

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

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

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

Returns the md5 sum of a field.

string
getLengthExpression(string $column)

Returns the length of a text field.

string
getSqrtExpression(string $column)

Returns the squared value of a column

string
getRoundExpression(string $column, integer $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, integer $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.

string
getLocateExpression(string $str, string $substr, integer $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 $length = 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(string $expression)

Returns the SQL for a logical not.

string
getInExpression(string $column, string|array $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, integer $days)

Add the number of given days to a date.

string
getDateSubDaysExpression(string $date, integer $days)

Substract the number of given days to a date.

string
getDateAddMonthExpression(string $date, integer $months)

Add the number of given months to a date.

string
getDateSubMonthExpression(string $date, integer $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, integer $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.

string
getDropDatabaseSQL(string $database)

Get the SQL snippet to drop an existing database

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, integer $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())

Gets the SQL used to create a table.

string
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
getCreateIndexSQLFlags(Index $index)

Adds additional flags for index generation

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

string
quoteSingleIdentifier(string $str)

Quote a single identifier (no dot chain separation)

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

Create a new foreign key

array
getAlterTableSQL(TableDiff $diff)

Gets the sql statements for altering an existing table.

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

No description

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

No description

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

No description

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

No description

boolean
onSchemaAlterTable(TableDiff $diff, array $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)

Some vendors require temporary table names to be qualified specially.

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

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

mixed
convertBooleans(mixed $item)

Some platforms need the boolean values to be converted.

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

string
_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)

No description

getListTablesSQL()

No description

getListUsersSQL()

No description

string
getListViewsSQL(string $database)

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

string
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

string
getDropSequenceSQL(Sequence $sequence)

Get the SQL snippet to drop an existing sequence

getSequenceNextValSQL($sequenceName)

No description

string
getCreateDatabaseSQL(string $database)

create a new database

string
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

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

boolean
supportsAlterTable()

Whether the platform supports altering tables.

boolean
supportsTransactions()

Whether the platform supports transactions.

boolean
supportsSavepoints()

Whether the platform supports savepoints.

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?

boolean
supportsForeignKeyOnUpdate()

Does this platform supports onUpdate in foreign key constraints?

boolean
supportsSchemas()

Whether the platform supports database schemas.

boolean
canEmulateSchemas()

Can this platform emulate schemas?

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

boolean
supportsInlineColumnComments()

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

boolean
supportsCommentOnStatement()

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

boolean
supportsViews()

Does this platform views ?

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

Modify limit query

string
doModifyLimitQuery(string $query, integer $limit, integer $offset)

Adds an driver-specific LIMIT clause to the query

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

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

integer
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, boolean $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

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

abstract string getBooleanTypeDeclarationSQL(array $columnDef)

Gets the SQL snippet that declares a boolean column.

Parameters

array $columnDef

Return Value

string

abstract string getIntegerTypeDeclarationSQL(array $columnDef)

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

Parameters

array $columnDef

Return Value

string

abstract string getBigIntTypeDeclarationSQL(array $columnDef)

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

Parameters

array $columnDef

Return Value

string

abstract string getSmallIntTypeDeclarationSQL(array $columnDef)

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

Parameters

array $columnDef

Return Value

string

abstract protected string _getCommonIntegerTypeDeclarationSQL(array $columnDef)

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

Parameters

array $columnDef

Return Value

string

abstract protected void initializeDoctrineTypeMappings()

Lazy load Doctrine Type Mappings

Return Value

void

string getVarcharTypeDeclarationSQL(array $field)

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

Parameters

array $field

Return Value

string

string getGuidTypeDeclarationSQL(array $field)

Get the SQL Snippet to create a GUID/UUID field.

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

Parameters

array $field

Return Value

string

protected string getVarcharTypeDeclarationSQLSnippet(integer $length, boolean $fixed)

Parameters

integer $length
boolean $fixed

Return Value

string

Exceptions

DBALException

abstract string getClobTypeDeclarationSQL(array $field)

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

Parameters

array $field

Return Value

string

abstract string getBlobTypeDeclarationSQL(array $field)

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

Parameters

array $field

Return Value

string

abstract 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

Exceptions

DBALException if the type is not found

string getDoctrineTypeMapping(string $dbType)

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

Parameters

string $dbType

Return Value

string

boolean hasDoctrineTypeMappingFor(string $dbType)

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

Parameters

string $dbType

Return Value

boolean

protected void initializeCommentedDoctrineTypes()

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

Return Value

void

boolean 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

boolean

void markDoctrineTypeCommented(string|Type $doctrineType)

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

Parameters

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

Returns the md5 sum of a field.

Note: Not SQL92, but common functionality

Parameters

string $column

Return Value

string

string getLengthExpression(string $column)

Returns the length of a text field.

Parameters

string $column

Return Value

string

string getSqrtExpression(string $column)

Returns 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, integer $decimals = 0)

Rounds a numeric field to the number of decimals specified.

Parameters

string $column
integer $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, integer $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
integer $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

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

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

Parameters

string $str literal string
string $substr literal string to find
integer $startPos position to start at, beginning of string by default

Return Value

string

string getNowExpression()

Returns the current system date.

Return Value

string

string getSubstringExpression(string $value, integer $from, integer $length = 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 $length 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(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 a logical expression

string getInExpression(string $column, string|array $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 $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, integer $days)

Add the number of given days to a date.

Parameters

string $date
integer $days

Return Value

string

string getDateSubDaysExpression(string $date, integer $days)

Substract the number of given days to a date.

Parameters

string $date
integer $days

Return Value

string

string getDateAddMonthExpression(string $date, integer $months)

Add the number of given months to a date.

Parameters

string $date
integer $months

Return Value

string

string getDateSubMonthExpression(string $date, integer $months)

Substract the number of given months to a date.

Parameters

string $date
integer $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, integer $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
integer $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

string getDropDatabaseSQL(string $database)

Get the SQL snippet to drop an existing database

Parameters

string $database name of the database that should be dropped

Return Value

string

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, integer $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.
integer $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())

Gets the SQL used to create a table.

Parameters

string $tableName
array $columns
array $options

Return Value

array

getCreateTemporaryTableSnippetSQL()

string getCreateSequenceSQL(Sequence $sequence)

Gets the SQL to create a sequence on this platform.

Parameters

Sequence $sequence

Return Value

string

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

protected string getCreateIndexSQLFlags(Index $index)

Adds additional flags for index generation

Parameters

Index $index

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

Return Value

string quoted identifier string

string quoteSingleIdentifier(string $str)

Quote a single identifier (no dot chain separation)

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 statements for altering an existing table.

The method returns an array of sql statements, since some platforms need several statements.

Parameters

TableDiff $diff

Return Value

array

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

Parameters

Column $column
TableDiff $diff
array $columnSql

Return Value

boolean

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

Parameters

Column $column
TableDiff $diff
array $columnSql

Return Value

boolean

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

Parameters

ColumnDiff $columnDiff
TableDiff $diff
array $columnSql

Return Value

boolean

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

Parameters

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

Return Value

boolean

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

Parameters

TableDiff $diff
array $sql

Return Value

boolean

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)

Some vendors require temporary table names to be qualified specially.

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

string getForeignKeyReferentialActionSQL(string $action)

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

Parameters

string $action foreign key referential action

Return Value

string

Exceptions

InvalidArgumentException 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

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

Parameters

mixed $item

Return Value

mixed

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 string _getTransactionIsolationLevelSQL(integer $level)

Get sql for transaction isolation level Connection constant

Parameters

integer $level

Return Value

string

getListDatabasesSQL()

getListSequencesSQL($database)

Parameters

$database

getListTableConstraintsSQL($table)

Parameters

$table

getListTableColumnsSQL($table, $database = null)

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

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

Return Value

string

getListTableForeignKeysSQL($table)

Parameters

$table

getCreateViewSQL($name, $sql)

Parameters

$name
$sql

getDropViewSQL($name)

Parameters

$name

string getDropSequenceSQL(Sequence $sequence)

Get the SQL snippet to drop an existing sequence

Parameters

Sequence $sequence

Return Value

string

getSequenceNextValSQL($sequenceName)

Parameters

$sequenceName

string getCreateDatabaseSQL(string $database)

create a new database

Parameters

string $database name of the database that should be created

Return Value

string

string getSetTransactionIsolationSQL(integer $level)

Get sql to set the transaction isolation level

Parameters

integer $level

Return Value

string

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

string getDateTimeTzTypeDeclarationSQL(array $fieldDeclaration)

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

Parameters

array $fieldDeclaration

Return Value

string

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

boolean supportsAlterTable()

Whether the platform supports altering tables.

Return Value

boolean

boolean supportsTransactions()

Whether the platform supports transactions.

Return Value

boolean

boolean supportsSavepoints()

Whether the platform supports 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

boolean supportsForeignKeyOnUpdate()

Does this platform supports onUpdate in foreign key constraints?

Return Value

boolean

boolean supportsSchemas()

Whether the platform supports database schemas.

Return Value

boolean

boolean 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

boolean

boolean supportsCreateDropDatabase()

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

Return Value

boolean

boolean supportsGettingAffectedRows()

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

Return Value

boolean

boolean supportsInlineColumnComments()

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

Return Value

boolean

boolean supportsCommentOnStatement()

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

Return Value

boolean

getIdentityColumnNullInsertSQL()

boolean supportsViews()

Does this platform views ?

Return Value

boolean

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

Modify limit query

Parameters

string $query
integer $limit
integer $offset

Return Value

string

protected string doModifyLimitQuery(string $query, integer $limit, integer $offset)

Adds an driver-specific LIMIT clause to the query

Parameters

string $query
integer $limit
integer $offset

Return Value

string

boolean supportsLimitOffset()

Does the database platform support offsets in modify limit clauses?

Return Value

boolean

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

integer getMaxIdentifierLength()

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

Return Value

integer

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, boolean $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
boolean $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