class PostgreSqlPlatform extends AbstractPlatform (View source)

PostgreSqlPlatform.

Constants

CREATE_INDEXES

CREATE_FOREIGNKEYS

TRIM_UNSPECIFIED

TRIM_LEADING

TRIM_TRAILING

TRIM_BOTH

Properties

protected array $doctrineTypeMapping from AbstractPlatform

Methods

__construct()

Constructor.

string
getBooleanTypeDeclarationSQL(array $field)

No description

string
getIntegerTypeDeclarationSQL(array $field)

No description

string
getBigIntTypeDeclarationSQL(array $field)

No description

string
getSmallIntTypeDeclarationSQL(array $field)

No description

string
_getCommonIntegerTypeDeclarationSQL(array $columnDef)

No description

void
initializeDoctrineTypeMappings()

Lazy load Doctrine Type Mappings

getVarcharTypeDeclarationSQL(array $field)

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

getVarcharTypeDeclarationSQLSnippet($length, $fixed)

Gets the SQL snippet used to declare a VARCHAR column on the MySql platform.

getClobTypeDeclarationSQL(array $field)

No description

string
getName()

Get the platform name for this instance

registerDoctrineTypeMapping(string $dbType, string $doctrineType)

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

string
getDoctrineTypeMapping(string $dbType)

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

bool
hasDoctrineTypeMappingFor(string $dbType)

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

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

Returns the average value of a column

string
getCountExpression(string|integer $column)

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

string
getMaxExpression(string $column)

Returns the highest value of a column

string
getMinExpression(string $column)

Returns the lowest value of a column

string
getSumExpression(string $column)

Returns the total sum of a column

string
getMd5Expression($column)

Returns the md5 sum of a field.

string
getLengthExpression($column)

Returns the length of a text field.

string
getRoundExpression($column, $decimals = 0)

Rounds a numeric field to the number of decimals specified.

string
getModExpression(string $expression1, string $expression2)

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

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

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

string
getRtrimExpression(string $str)

rtrim returns the string $str with proceeding space characters removed

string
getLtrimExpression(string $str)

ltrim returns the string $str with leading space characters removed

string
getUpperExpression(string $str)

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

string
getLowerExpression(string $str)

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

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

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

string
getNowExpression()

Returns the SQL string to return the current system date and time.

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

Returns part of a string.

string
getConcatExpression()

Returns a series of strings concatinated

string
getNotExpression($expression)

Returns the SQL for a logical not.

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

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

string
getIsNullExpression(string $expression)

Returns SQL that checks if a expression is null.

string
getIsNotNullExpression(string $expression)

Returns SQL that checks if a expression is not null.

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

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

getAcosExpression($value)

No description

getSinExpression($value)

No description

getPiExpression()

No description

getCosExpression($value)

No description

getForUpdateSQL()

No description

string
appendLockHint(string $fromClause, int $lockMode)

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

string
getReadLockSQL()

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

string
getWriteLockSQL()

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

getDropDatabaseSQL(string $name)

drop an existing database

string
getDropTableSQL(Table|string $table)

Drop a Table

string
getDropIndexSQL($index, $table = null)

Drop index from a table

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

Get drop constraint sql

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

No description

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

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

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

Gets the SQL used to create a table.

getCreateSequenceSQL(Sequence $sequence)

Gets the SQL to create a sequence on this platform.

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

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

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

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

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

Get SQL to create an unnamed primary key constraint.

string
quoteIdentifier(string $str)

Quotes a string so that it can be safely used as a table or column name, even if it is a reserved word of the platform.

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

Create a new foreign key

array
getAlterTableSQL(TableDiff $diff)

generates the sql for altering an existing table on postgresql

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

getForeignKeyReferentialActionSQL($action)

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

string
getForeignKeyBaseDeclarationSQL(ForeignKeyConstraint $foreignKey)

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

string
getUniqueFieldDeclarationSQL()

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

string
getColumnCharsetDeclarationSQL(string $charset)

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

string
getColumnCollationDeclarationSQL(string $collation)

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

boolean
prefersSequences()

Whether the platform prefers sequences for ID generation.

boolean
prefersIdentityColumns()

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

convertBooleans(mixed $item)

Postgres wants boolean values converted to the strings 'true'/'false'.

string
getSetCharsetSQL(string $charset)

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

string
getCurrentDateSQL()

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

string
getCurrentTimeSQL()

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

string
getCurrentTimestampSQL()

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

_getTransactionIsolationLevelSQL(integer $level)

Get sql for transaction isolation level Connection constant

getListDatabasesSQL()

No description

getListSequencesSQL($database)

No description

getListTableConstraintsSQL($table)

No description

getListTableColumnsSQL($table)

No description

getListTablesSQL()

No description

getListUsersSQL()

No description

string
getListViewsSQL(string $database)

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

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

No description

getListTableForeignKeysSQL($table, $database = null)

No description

getCreateViewSQL($name, $sql)

No description

getDropViewSQL($name)

No description

getDropSequenceSQL($sequence)

Drop existing sequence

getSequenceNextValSQL($sequenceName)

No description

getCreateDatabaseSQL(string $name)

create a new database

getSetTransactionIsolationSQL(integer $level)

Get sql to set the transaction isolation level

string
getDateTimeTypeDeclarationSQL(array $fieldDeclaration)

No description

getDateTimeTzTypeDeclarationSQL(array $fieldDeclaration)

No description

string
getDateTypeDeclarationSQL(array $fieldDeclaration)

No description

string
getTimeTypeDeclarationSQL(array $fieldDeclaration)

No description

getFloatDeclarationSQL(array $fieldDeclaration)

No description

integer
getDefaultTransactionIsolationLevel()

Gets the default transaction isolation level of the platform.

boolean
supportsSequences()

Whether the platform supports sequences.

boolean
supportsIdentityColumns()

Whether the platform supports identity columns.

boolean
supportsIndexes()

Whether the platform supports indexes.

supportsAlterTable()

No description

boolean
supportsTransactions()

Whether the platform supports transactions.

boolean
supportsSavepoints()

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?

bool
supportsForeignKeyOnUpdate()

Does this platform supports onUpdate in foreign key constraints?

boolean
supportsSchemas()

Whether the platform supports database schemas.

bool
supportsCreateDropDatabase()

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

boolean
supportsGettingAffectedRows()

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

string
getDateTimeFormatString()

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

string
getDateTimeTzFormatString()

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

string
getDateFormatString()

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

string
getTimeFormatString()

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

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

Modify limit query

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

No description

string
getSQLResultCasing(string $column)

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

string
fixSchemaElementName($schemaElementName)

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

int
getMaxIdentifierLength()

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

string
getEmptyIdentityInsertSQL($quotedTableName, $quotedIdentifierColumnName)

Get the insert sql for an empty insert statement

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

No description

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

Details

__construct()

Constructor.

string getBooleanTypeDeclarationSQL(array $field)

Parameters

array $field

Return Value

string

string getIntegerTypeDeclarationSQL(array $field)

Parameters

array $field

Return Value

string

string getBigIntTypeDeclarationSQL(array $field)

Parameters

array $field

Return Value

string

string getSmallIntTypeDeclarationSQL(array $field)

Parameters

array $field

Return Value

string

protected string _getCommonIntegerTypeDeclarationSQL(array $columnDef)

Parameters

array $columnDef

Return Value

string

protected void initializeDoctrineTypeMappings()

Lazy load Doctrine Type Mappings

Return Value

void

getVarcharTypeDeclarationSQL(array $field)

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

Parameters

array $field

protected getVarcharTypeDeclarationSQLSnippet($length, $fixed)

Gets the SQL snippet used to declare a VARCHAR column on the MySql platform.

Parameters

$length
$fixed

getClobTypeDeclarationSQL(array $field)

Parameters

array $field

string getName()

Get the platform name for this instance

Return Value

string

registerDoctrineTypeMapping(string $dbType, string $doctrineType)

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

Parameters

string $dbType
string $doctrineType

string getDoctrineTypeMapping(string $dbType)

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

Parameters

string $dbType

Return Value

string

bool hasDoctrineTypeMappingFor(string $dbType)

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

Parameters

string $dbType

Return Value

bool

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

regexp

Return Value

string

string getAvgExpression(string $column)

Returns the average value of a column

Parameters

string $column the column to use

Return Value

string generated sql including an AVG aggregate function

string getCountExpression(string|integer $column)

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

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

Parameters

string|integer $column the column to use

Return Value

string generated sql including a COUNT aggregate function

string getMaxExpression(string $column)

Returns the highest value of a column

Parameters

string $column the column to use

Return Value

string generated sql including a MAX aggregate function

string getMinExpression(string $column)

Returns the lowest value of a column

Parameters

string $column the column to use

Return Value

string

string getSumExpression(string $column)

Returns the total sum of a column

Parameters

string $column the column to use

Return Value

string

string getMd5Expression($column)

Returns the md5 sum of a field.

Note: Not SQL92, but common functionality

Parameters

$column

Return Value

string

string getLengthExpression($column)

Returns the length of a text field.

Parameters

$column

Return Value

string

string getRoundExpression($column, $decimals = 0)

Rounds a numeric field to the number of decimals specified.

Parameters

$column
$decimals

Return Value

string

string getModExpression(string $expression1, string $expression2)

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

Parameters

string $expression1
string $expression2

Return Value

string

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

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

Parameters

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

Return Value

string

string getRtrimExpression(string $str)

rtrim returns the string $str with proceeding space characters removed

Parameters

string $str literal string or column name

Return Value

string

string getLtrimExpression(string $str)

ltrim returns the string $str with leading space characters removed

Parameters

string $str literal string or column name

Return Value

string

string getUpperExpression(string $str)

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

Parameters

string $str literal string or column name

Return Value

string

string getLowerExpression(string $str)

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

Parameters

string $str literal string or column name

Return Value

string

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

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

Parameters

$str
$substr
$startPos

Return Value

integer

string getNowExpression()

Returns the SQL string to return the current system date and time.

Return Value

string

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

Returns part of a string.

Note: Not SQL92, but common functionality.

Parameters

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

Return Value

string

string getConcatExpression()

Returns a series of strings concatinated

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

Return Value

string

string getNotExpression($expression)

Returns the SQL for a logical not.

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

Parameters

$expression

Return Value

string a logical expression

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

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

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

Parameters

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

Return Value

string logical expression

string getIsNullExpression(string $expression)

Returns SQL that checks if a expression is null.

Parameters

string $expression the expression that should be compared to null

Return Value

string logical expression

string getIsNotNullExpression(string $expression)

Returns SQL that checks if a expression is not null.

Parameters

string $expression the expression that should be compared to null

Return Value

string logical expression

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

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

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

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

Parameters

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

Return Value

string logical expression

getAcosExpression($value)

Parameters

$value

getSinExpression($value)

Parameters

$value

getPiExpression()

getCosExpression($value)

Parameters

$value

getForUpdateSQL()

string appendLockHint(string $fromClause, int $lockMode)

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

Parameters

string $fromClause
int $lockMode

Return Value

string

string getReadLockSQL()

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

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

Return Value

string

string getWriteLockSQL()

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

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

Return Value

string

getDropDatabaseSQL(string $name)

drop an existing database

Parameters

string $name name of the database that should be dropped

Exceptions

PDOException

string getDropTableSQL(Table|string $table)

Drop a Table

Parameters

Table|string $table

Return Value

string

string getDropIndexSQL($index, $table = null)

Drop index from a table

Parameters

$index
$table

Return Value

string

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

Get drop constraint sql

Parameters

Constraint $constraint
string|Table $table

Return Value

string

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

Parameters

ForeignKeyConstraint|string $foreignKey
Table|string $table

Return Value

string

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

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

Parameters

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

Return Value

array The sequence of SQL statements.

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

getCreateSequenceSQL(Sequence $sequence)

Gets the SQL to create a sequence on this platform.

Parameters

Sequence $sequence

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

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

Parameters

Constraint $constraint
string|Table $table

Return Value

string

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

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

Parameters

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

Return Value

string

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

Get SQL to create an unnamed primary key constraint.

Parameters

Index $index
string|Table $table

Return Value

string

string quoteIdentifier(string $str)

Quotes a string so that it can be safely used as a table or column name, even if it is a reserved word of the platform.

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

generates the sql for altering an existing table on postgresql

Parameters

TableDiff $diff

Return Value

array

See also

Doctrine_Export::alterTable()

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

getForeignKeyReferentialActionSQL($action)

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

Parameters

$action

Exceptions

Doctrine_Exception_Exception if unknown referential action given

string getForeignKeyBaseDeclarationSQL(ForeignKeyConstraint $foreignKey)

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

Parameters

ForeignKeyConstraint $foreignKey

Return Value

string

string getUniqueFieldDeclarationSQL()

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

Return Value

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

string getColumnCharsetDeclarationSQL(string $charset)

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

Parameters

string $charset name of the charset

Return Value

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

string getColumnCollationDeclarationSQL(string $collation)

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

Parameters

string $collation name of the collation

Return Value

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

boolean prefersSequences()

Whether the platform prefers sequences for ID generation.

Return Value

boolean

boolean prefersIdentityColumns()

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

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

Return Value

boolean

convertBooleans(mixed $item)

Postgres wants boolean values converted to the strings 'true'/'false'.

Parameters

mixed $item

string getSetCharsetSQL(string $charset)

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

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

Parameters

string $charset

Return Value

string

string getCurrentDateSQL()

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

Return Value

string

string getCurrentTimeSQL()

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

Return Value

string

string getCurrentTimestampSQL()

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

Return Value

string

protected _getTransactionIsolationLevelSQL(integer $level)

Get sql for transaction isolation level Connection constant

Parameters

integer $level

getListDatabasesSQL()

getListSequencesSQL($database)

Parameters

$database

getListTableConstraintsSQL($table)

Parameters

$table

getListTableColumnsSQL($table)

Parameters

$table

getListTablesSQL()

getListUsersSQL()

string getListViewsSQL(string $database)

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

Parameters

string $database

Return Value

string

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

Parameters

string $table
string $currentDatabase

getListTableForeignKeysSQL($table, $database = null)

Parameters

$table
$database

getCreateViewSQL($name, $sql)

Parameters

$name
$sql

getDropViewSQL($name)

Parameters

$name

getDropSequenceSQL($sequence)

Drop existing sequence

Parameters

$sequence

getSequenceNextValSQL($sequenceName)

Parameters

$sequenceName

getCreateDatabaseSQL(string $name)

create a new database

Parameters

string $name name of the database that should be created

Exceptions

PDOException

getSetTransactionIsolationSQL(integer $level)

Get sql to set the transaction isolation level

Parameters

integer $level

string getDateTimeTypeDeclarationSQL(array $fieldDeclaration)

Parameters

array $fieldDeclaration

Return Value

string

getDateTimeTzTypeDeclarationSQL(array $fieldDeclaration)

Parameters

array $fieldDeclaration

string getDateTypeDeclarationSQL(array $fieldDeclaration)

Parameters

array $fieldDeclaration

Return Value

string

string getTimeTypeDeclarationSQL(array $fieldDeclaration)

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.

Postgres has native support for sequences.

Return Value

boolean

boolean supportsIdentityColumns()

Whether the platform supports identity columns.

Postgres supports these through the SERIAL keyword.

Return Value

boolean

boolean supportsIndexes()

Whether the platform supports indexes.

Return Value

boolean

supportsAlterTable()

boolean supportsTransactions()

Whether the platform supports transactions.

Return Value

boolean

boolean supportsSavepoints()

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

bool supportsForeignKeyOnUpdate()

Does this platform supports onUpdate in foreign key constraints?

Return Value

bool

boolean supportsSchemas()

Whether the platform supports database schemas.

Return Value

boolean

bool supportsCreateDropDatabase()

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

Return Value

bool

boolean supportsGettingAffectedRows()

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

Return Value

boolean

getIdentityColumnNullInsertSQL()

string getDateTimeFormatString()

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

Return Value

string The format string.

string getDateTimeTzFormatString()

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

Return Value

string The format string.

string getDateFormatString()

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

Return Value

string The format string.

string getTimeFormatString()

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

Return Value

string The format string.

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

Modify limit query

Parameters

string $query
int $limit
int $offset

Return Value

string

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

Parameters

string $query
int $limit
int $offset

Return Value

string

string getSQLResultCasing(string $column)

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

PostgreSQL returns all column names in SQL result sets in lowercase.

Parameters

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

Return Value

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

string fixSchemaElementName($schemaElementName)

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

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

Parameters

$schemaElementName

Return Value

string

int getMaxIdentifierLength()

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

Return Value

int

string getEmptyIdentityInsertSQL($quotedTableName, $quotedIdentifierColumnName)

Get the insert sql for an empty insert statement

Parameters

$quotedTableName
$quotedIdentifierColumnName

Return Value

string $sql

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

Parameters

string $tableName
bool $cascade

Return Value

string

string getDummySelectSQL()

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

Return Value

string

string createSavePoint(string $savepoint)

Generate SQL to create a new savepoint

Parameters

string $savepoint

Return Value

string

string releaseSavePoint(string $savepoint)

Generate SQL to release a savepoint

Parameters

string $savepoint

Return Value

string

string rollbackSavePoint(string $savepoint)

Generate SQL to rollback a savepoint

Parameters

string $savepoint

Return Value

string