Summary
- File
- Package hierarchy DBAL\Plateform
- Class hierarchy \AbstractPlatform \PostgreSqlPlatform
- See also https://www.doctrine-project.org
PostgreSqlPlatform.
They are a passive source of information.
PostgreSqlPlatform.
They are a passive source of information.
__construct()
Constructor.
Creates a new PostgreSqlPlatform.
None found |
getIdentifierQuoteCharacter() : string
Gets the character used for identifier quoting.
None found |
getSqlCommentStartString() : string
Gets the string portion that starts an SQL comment.
None found |
getSqlCommentEndString() : string
Gets the string portion that ends an SQL comment.
None found |
getVarcharMaxLength() : integer
Gets the maximum length of a varchar field.
None found |
getWildcards() : array
Gets all SQL wildcard characters of the platform.
None found |
getRegexpExpression() : string
regexp
the regular expression operator
override |
getAvgExpression(string $column) : string
Returns the average value of a column
string | $column | the column to use |
generated sql including an AVG aggregate function
None found |
getCountExpression(string|integer $column) : string
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.
string|integer | $column | the column to use |
generated sql including a COUNT aggregate function
None found |
getMaxExpression(string $column) : string
Returns the highest value of a column
string | $column | the column to use |
generated sql including a MAX aggregate function
None found |
getMinExpression(string $column) : string
Returns the lowest value of a column
string | $column | the column to use |
None found |
getSumExpression(string $column) : string
Returns the total sum of a column
string | $column | the column to use |
None found |
getMd5Expression( $column) : string
Returns the md5 sum of a field.
Note: Not SQL92, but common functionality
md5() works with the default PostgreSQL 8 versions.
If you are using PostgreSQL 7.x or older you need
to make sure that the digest procedure is installed.
If you use RPMS (Redhat and Mandrake) install the postgresql-contrib
package. You must then install the procedure by running this shell command:
psql [dbname] < /usr/share/pgsql/contrib/pgcrypto.sql
You should make sure you run this as the postgres user.
$column |
override |
getLengthExpression( $column) : string
Returns the length of a text field.
$column |
None found |
getRoundExpression( $column, $decimals) : string
Rounds a numeric field to the number of decimals specified.
$column | ||
$decimals |
None found |
getModExpression(string $expression1, string $expression2) : string
Returns the remainder of the division operation $expression1 / $expression2.
string | $expression1 | |
string | $expression2 |
None found |
getTrimExpression(string $str) : string
trim returns the string $str with leading and proceeding space characters removed
string | $str | literal string or column name |
None found |
getRtrimExpression(string $str) : string
rtrim returns the string $str with proceeding space characters removed
string | $str | literal string or column name |
None found |
getLtrimExpression(string $str) : string
ltrim returns the string $str with leading space characters removed
string | $str | literal string or column name |
None found |
getUpperExpression(string $str) : string
upper Returns the string $str with all characters changed to uppercase according to the current character set mapping.
string | $str | literal string or column name |
None found |
getLowerExpression(string $str) : string
lower Returns the string $str with all characters changed to lowercase according to the current character set mapping.
string | $str | literal string or column name |
None found |
getLocateExpression(string $str, string $substr) : integer
locate returns the position of the first occurrence of substring $substr in string $str
string | $str | literal string |
string | $substr | literal string to find |
None found |
getNowExpression() : string
Returns the SQL string to return the current system date and time.
None found |
getSubstringExpression(string $value, integer $from, integer $len = null) : string
Returns part of a string.
Note: Not SQL92, but common functionality.
string | $value | the target $value the string or the string column. |
integer | $from | extract from this characeter. |
integer | $len | extract this amount of characters. |
sql that extracts part of a string.
override |
getConcatExpression() : string
Returns a series of strings concatinated
concat() accepts an arbitrary number of parameters. Each parameter must contain an expression
None found |
getNotExpression( $expression) : string
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'));
$expression |
a logical expression
None found |
getInExpression(string $column, $values) : string
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.
string | $column | the value that should be matched against |
$values |
logical expression
None found |
getIsNullExpression(string $expression) : string
Returns SQL that checks if a expression is null.
string | $expression | the expression that should be compared to null |
logical expression
None found |
getIsNotNullExpression(string $expression) : string
Returns SQL that checks if a expression is not null.
string | $expression | the expression that should be compared to null |
logical expression
None found |
getBetweenExpression(string $expression, string $value1, string $value2) : string
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().
string | $expression | the value to compare to |
string | $value1 | the lower value to compare with |
string | $value2 | the higher value to compare with |
logical expression
None found |
getAcosExpression( $value)
$value |
None found |
getSinExpression( $value)
$value |
None found |
getPiExpression()
None found |
getCosExpression( $value)
$value |
None found |
getForUpdateSql()
None found |
getDropDatabaseSql(string $name)
drop an existing database
string | $name | name of the database that should be dropped |
None found |
getDropTableSql( $table)
$table |
None found |
getDropIndexSql( $table, $name)
$table | ||
$name |
None found |
getDropConstraintSql( $table, $name, $primary = false)
$table | ||
$name | ||
$primary |
None found |
getDropForeignKeySql( $table, $name)
$table | ||
$name |
None found |
getCreateTableSql(\unknown_type $name, array $fields, array $options = array()) : \unknown
Gets the SQL used to create a table.
\unknown_type | $name | |
array | $fields | |
array | $options | The table constraints. |
None found |
getCreateTemporaryTableSnippetSql()
None found |
getCreateSequenceSql(string $sequenceName, integer $start = 1, integer $allocationSize = 1) : string
Gets the SQL to create a sequence on this platform.
string | $sequenceName | |
integer | $start | |
integer | $allocationSize |
override |
getCreateConstraintSql(string $table, string $name, array $definition) : string
Gets the SQL to create a constraint on a table on this platform.
string | $table | name of the table on which the constraint is to be created |
string | $name | name of the constraint to be created |
array | $definition | associative array that defines properties of the constraint to be created. Currently, only one property named FIELDS is supported. This property is also an associative with the names of the constraint fields as array constraints. Each entry of this array is set to another type of associative array that specifies properties of the constraint that are specific to each field.
|
None found |
getCreateIndexSql(string $table, string $name, array $definition) : string
Gets the SQL to create an index on a table on this platform.
string | $table | name of the table on which the index is to be created |
string | $name | name of the index to be created |
array | $definition | associative array that defines properties of the index to be created. |
None found |
quoteIdentifier(string $str) : string
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.
string | $str | identifier name to be quoted |
quoted identifier string
None found |
getCreateForeignKeySql(string $table, array $definition) : string
createForeignKeySql
string | $table | name of the table on which the foreign key is to be created |
array | $definition | associative array that defines properties of the foreign key to be created. |
None found |
getAlterTableSql(string $name, array $changes, boolean $check = false) : array
generates the sql for altering an existing table on postgresql
(this method is implemented by the drivers)
string | $name | name of the table that is intended to be changed. |
array | $changes | associative array that contains the details of each type * |
boolean | $check | indicates whether the function should just check if the DBMS driver can perform the requested table alterations if the value is true or actually perform them otherwise. |
override |
getColumnDeclarationListSql(array $fields) : string
Get declaration of a number of fields in bulk
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:
|
None found |
getColumnDeclarationSql(string $name, array $field) : string
Obtain DBMS specific SQL code portion needed to declare a generic type field to be used in statements like CREATE TABLE.
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:
|
DBMS specific SQL code portion that should be used to declare the column.
None found |
getDecimalTypeDeclarationSql(array $columnDef) : string
Gets the SQL snippet that declares a floating point column of arbitrary precision.
array | $columnDef |
None found |
getFloatTypeDeclarationSql(array $fieldDeclaration)
array | $fieldDeclaration |
None found |
getBooleanTypeDeclarationSql(array $field) : string
Gets the SQL snippet that declares a boolean column.
array | $field |
override |
getIntegerTypeDeclarationSql(array $field) : string
Gets the SQL snippet that declares a 4 byte integer column.
array | $field |
override |
getBigIntTypeDeclarationSql(array $field) : string
Gets the SQL snippet that declares an 8 byte integer column.
array | $field |
override |
getSmallIntTypeDeclarationSql(array $field) : string
Gets the SQL snippet that declares a 2 byte integer column.
array | $field |
override |
getDefaultValueDeclarationSql(array $field) : string
Obtain DBMS specific SQL code portion needed to set a default value declaration to be used in statements like CREATE TABLE.
array | $field | field definition array |
DBMS specific SQL code portion needed to set a default value
override |
getCheckDeclarationSql(array $definition) : string
Obtain DBMS specific SQL code portion needed to set a CHECK constraint declaration to be used in statements like CREATE TABLE.
array | $definition | check definition |
DBMS specific SQL code portion needed to set a CHECK constraint
None found |
getIndexDeclarationSql(string $name, array $definition) : string
Obtain DBMS specific SQL code portion needed to set an index declaration to be used in statements like CREATE TABLE.
string | $name | name of the index |
array | $definition | index definition |
DBMS specific SQL code portion needed to set an index
None found |
getIndexFieldDeclarationListSql(array $fields) : string
getIndexFieldDeclarationList Obtain DBMS specific SQL code portion needed to set an index declaration to be used in statements like CREATE TABLE.
array | $fields |
None found |
getTemporaryTableSql() : string
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".
The string required to be placed between "CREATE" and "TABLE" to generate a temporary table, if possible.
None found |
getShowDatabasesSql() : \unknown
Get sql query to show a list of database
None found |
getForeignKeyDeclarationSql(array $definition) : string
getForeignKeyDeclaration 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.
array | $definition | an associative array with the following structure: name optional constraint name
The onDelete and onUpdate keys accept the following values: CASCADE: Delete or update the row from the parent table and automatically delete or update the matching rows in the child table. Both ON DELETE CASCADE and ON UPDATE CASCADE are supported. Between two tables, you should not define several ON UPDATE CASCADE clauses that act on the same column in the parent table or in the child table. SET NULL: Delete or update the row from the parent table and set the foreign key column or columns in the child table to NULL. This is valid only if the foreign key columns do not have the NOT NULL qualifier specified. Both ON DELETE SET NULL and ON UPDATE SET NULL clauses are supported. NO ACTION: In standard SQL, NO ACTION means no action in the sense that an attempt to delete or update a primary key value is not allowed to proceed if there is a related foreign key value in the referenced table. RESTRICT: Rejects the delete or update operation for the parent table. NO ACTION and RESTRICT are the same as omitting the ON DELETE or ON UPDATE clause. SET DEFAULT |
DBMS specific SQL code portion needed to set the FOREIGN KEY constraint of a field declaration.
None found |
getAdvancedForeignKeyOptionsSql(array $definition) : string
getAdvancedForeignKeyOptions Return the FOREIGN KEY query section dealing with non-standard options as MATCH, INITIALLY DEFERRED, ON UPDATE, .
..
array | $definition | foreign key definition |
override |
getForeignKeyReferentialActionSql(string $action)
returns given referential action in uppercase if valid, otherwise throws an exception
string | $action | foreign key referential action |
if unknown referential action given
None found |
getForeignKeyBaseDeclarationSql(array $definition) : string
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.
array | $definition |
None found |
getUniqueFieldDeclarationSql() : string
Obtain DBMS specific SQL code portion needed to set the UNIQUE constraint of a field declaration to be used in statements like CREATE TABLE.
DBMS specific SQL code portion needed to set the UNIQUE constraint of a field declaration.
None found |
getColumnCharsetDeclarationSql(string $charset) : string
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 | $charset | name of the charset |
DBMS specific SQL code portion needed to set the CHARACTER SET of a field declaration.
None found |
getColumnCollationDeclarationSql(string $collation) : string
Obtain DBMS specific SQL code portion needed to set the COLLATION of a field declaration to be used in statements like CREATE TABLE.
string | $collation | name of the collation |
DBMS specific SQL code portion needed to set the COLLATION of a field declaration.
None found |
getMatchPatternExpression(array $pattern, string $operator = null, string $field = null) : string
build a pattern matching string
EXPERIMENTAL
WARNING: this function is experimental and may change signature at any time until labelled as non-experimental
array | $pattern | even keys are strings, odd are patterns (% and _) |
string | $operator | optional pattern operator (LIKE, ILIKE and maybe others in the future) |
string | $field | optional field name that is being matched against (might be required when emulating ILIKE) |
SQL pattern
override |
prefersSequences() : boolean
Whether the platform prefers sequences for ID generation.
Subclasses should override this method to return TRUE if they prefer sequences.
None found |
prefersIdentityColumns() : boolean
Whether the platform prefers identity columns (eg. autoincrement) for ID generation.
Subclasses should override this method to return TRUE if they prefer identity columns.
None found |
writeLimitClause(string $query, mixed $limit = false, mixed $offset = false)
Adds a LIMIT/OFFSET clause to the query.
This default implementation writes the syntax "LIMIT x OFFSET y" to the query which is supported by MySql, PostgreSql and Sqlite. Any database platforms that do not support this syntax should override this implementation and provide their own.
string | $query | The SQL string to write to / append to. |
mixed | $limit | |
mixed | $offset |
None found |
convertBooleans(array $item)
Postgres wants boolean values converted to the strings 'true'/'false'.
Default conversion defined here converts to integers.
array | $item |
override |
getSetCharsetSql(string $charset) : string
Gets the SQL statement specific for the platform to set the charset.
string | $charset |
None found |
getCurrentDateSql() : string
Gets the SQL specific for the platform to get the current date.
None found |
getCurrentTimeSql() : string
Gets the SQL specific for the platform to get the current time.
None found |
getCurrentTimestampSql() : string
Gets the SQL specific for the platform to get the current timestamp
None found |
getListDatabasesSql()
None found |
getListFunctionsSql()
None found |
getListTriggersSql( $table = null)
$table |
None found |
getListSequencesSql( $database)
$database |
None found |
getListTableConstraintsSql( $table)
$table |
None found |
getListTableColumnsSql( $table)
$table |
None found |
getListTablesSql()
None found |
getListUsersSql()
None found |
getListViewsSql()
None found |
getListTableIndexesSql( $table)
$table |
None found |
getListTableForeignKeysSql( $table, $database = null)
$table | ||
$database |
None found |
getCreateViewSql( $name, $sql)
$name | ||
$sql |
None found |
getDropViewSql( $name)
$name |
None found |
getDropSequenceSql(string $sequenceName)
drop existing sequence
string | $sequenceName | name of the sequence to be dropped |
override |
getSequenceNextValSql( $sequenceName)
$sequenceName |
None found |
getCreateDatabaseSql(string $name) : void
create a new database
string | $name | name of the database that should be created |
override |
getSetTransactionIsolationSql(integer $level)
Get sql to set the transaction isolation level
integer | $level |
None found |
getCharsetFieldDeclaration(string $charset) : string
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 | $charset | name of the charset |
DBMS specific SQL code portion needed to set the CHARACTER SET of a field declaration.
None found |
getDateTimeTypeDeclarationSql(array $fieldDeclaration) : string
Obtain DBMS specific SQL to be used to create datetime fields in statements like CREATE TABLE
array | $fieldDeclaration |
override |
getDateTypeDeclarationSql(array $fieldDeclaration) : string
Obtain DBMS specific SQL to be used to create date fields in statements like CREATE TABLE.
array | $fieldDeclaration |
override |
getDefaultTransactionIsolationLevel() : integer
Gets the default transaction isolation level of the platform.
The default isolation level.
None found |
supportsSequences() : boolean
Whether the platform supports sequences.
Postgres has native support for sequences.
None found |
supportsIdentityColumns() : boolean
Whether the platform supports identity columns.
Postgres supports these through the SERIAL keyword.
None found |
supportsIndexes() : boolean
Whether the platform supports indexes.
None found |
supportsTransactions() : boolean
Whether the platform supports transactions.
None found |
supportsSavepoints() : boolean
Whether the platform supports savepoints.
None found |
supportsPrimaryConstraints() : boolean
Whether the platform supports primary key constraints.
None found |
supportsForeignKeyConstraints() : boolean
Whether the platform supports foreign key constraints.
None found |
supportsSchemas() : boolean
Whether the platform supports database schemas.
None found |
supportsGettingAffectedRows() : boolean
Whether the platform supports getting the affected rows of a recent update/delete type query.
None found |
getIdentityColumnNullInsertSql()
None found |
getDateTimeFormatString() : string
Gets the format string, as accepted by the date() function, that describes the format of a stored datetime value of this platform.
The format string.
None found |
getDateFormatString() : string
Gets the format string, as accepted by the date() function, that describes the format of a stored date value of this platform.
The format string.
None found |
getTimeFormatString() : string
Gets the format string, as accepted by the date() function, that describes the format of a stored time value of this platform.
The format string.
None found |
modifyLimitQuery( $query, $limit, $offset = null)
$query | ||
$limit | ||
$offset |
None found |
getVarcharTypeDeclarationSql(array $field)
Gets the SQL snippet used to declare a VARCHAR column on the MySql platform.
array | $field |
params |
array $field |
override |
getClobTypeDeclarationSql(array $field)
Gets the SQL snippet used to declare a CLOB column type.
array | $field |
override |
getName() : string
Get the platform name for this instance
None found |
getSqlResultCasing(string $column) : string
Gets the character casing of a column in an SQL result set.
PostgreSQL returns all column names in SQL result sets in lowercase.
string | $column | The column name for which to get the correct character casing. |
The column name in the character casing used in SQL result sets.
None found |
fixSchemaElementName( $schemaElementName) : string
Makes any fixes to a name of a schema element (table, sequence, .
..) that are required by restrictions of the platform, like a maximum length.
$schemaElementName |
None found |
getEmptyIdentityInsertSql( $quotedTableName, $quotedIdentifierColumnName) : string
Get the insert sql for an empty insert statement
$quotedTableName | ||
$quotedIdentifierColumnName |
$sql
None found |
getAgeExpression(string $timestamp1, string $timestamp2 = null) : string
PostgreSQLs AGE(<timestamp1> [, <timestamp2>]) function.
string | $timestamp1 | timestamp to subtract from NOW() |
string | $timestamp2 | optional; if given: subtract arguments |
None found |
getDatePartExpression(string $text, string $time) : string
PostgreSQLs DATE_PART( <text>, <time> ) function.
string | $text | what to extract |
string | $time | timestamp or interval to extract from |
None found |
getToCharExpression(string $time, string $text) : string
PostgreSQLs TO_CHAR( <time>, <text> ) function.
string | $time | timestamp or interval |
string | $text | how to the format the output |
None found |
getRandomExpression() : \return
return string to call a function to get random value inside an SQL statement
string to generate float between 0 and 1
override |
_getCommonIntegerTypeDeclarationSql(array $columnDef) : string
Gets the SQL snippet that declares common properties of an integer column.
array | $columnDef |
override |
_getTransactionIsolationLevelSql(integer $level)
Get sql for transaction isolation level Connection constant
integer | $level |
None found |