AbstractPlatform
public abstract class AbstractPlatform
www.doctrine-project.org
Field Summary | |
---|---|
final int | |
final int | |
final int | |
final int | |
final int | |
final int |
Constructor Summary | |
---|---|
Constructor. |
Method Summary | |
---|---|
void | convertBooleans(mixed item) Some platforms need the boolean values to be converted. |
bool | |
string | fixSchemaElementName(mixed schemaElementName, string schemaName) Makes any fixes to a name of a schema element (table, sequence, ...) that are required by restrictions of the platform, like a maximum length. |
void | getAcosExpression(mixed value) |
string | getAdvancedForeignKeyOptionsSQL(ForeignKeyConstraint foreignKey) Return the FOREIGN KEY query section dealing with non-standard options as MATCH, INITIALLY DEFERRED, ON UPDATE, ... |
array | getAlterTableSQL(TableDiff diff) Gets the sql statements for altering an existing table. |
string | getAvgExpression(string column) Returns the average value of a column |
string | getBetweenExpression(string expression, string value1, string value2) Returns SQL that checks if an expression evaluates to a value between two values. |
abstract string | getBigIntTypeDeclarationSQL(array columnDef) Gets the SQL snippet that declares an 8 byte integer column. |
abstract string | getBooleanTypeDeclarationSQL(array columnDef) Gets the SQL snippet that declares a boolean column. |
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. |
abstract void | getClobTypeDeclarationSQL(array field) Gets the SQL snippet used to declare a CLOB column type. |
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. |
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 | getConcatExpression(string arg1,) Returns a series of strings concatinatedconcat() accepts an arbitrary number of parameters. |
void | getCosExpression(mixed value) |
string | getCountExpression(string|integer column) Returns the number of rows (without a NULL value) of a columnIf a '*' is used instead of a column the number of selected rows is returned. |
string | getCreateConstraintSQL(Constraint constraint, string|Table table) Gets the SQL to create a constraint on a table on this platform. |
void | getCreateDatabaseSQL(mixed database) |
string | getCreateForeignKeySQL(ForeignKeyConstraint foreignKey, string|Table table) Create a new foreign key |
string | getCreateIndexSQL(Index index, string|Table table) Gets the SQL to create an index on a table on this platform. |
void | getCreateSequenceSQL(\Doctrine\DBAL\Schema\Sequence sequence) Gets the SQL to create a sequence on this platform. |
array | getCreateTableSQL(string table, int createFlags) Gets the SQL statement(s) to create a table with the specified name, columns and constraints on this platform. |
void | |
void | getCreateViewSQL(mixed name, mixed sql) |
string | Gets the SQL specific for the platform to get the current date. |
string | Gets the SQL specific for the platform to get the current time. |
string | Gets the SQL specific for the platform to get the current timestamp |
string | getCustomTypeDeclarationSQL(mixed columnDef) getCustomTypeDeclarationSql Obtail SQL code portion needed to create a custom column, e.g. |
string | Gets the format string, as accepted by the date() function, that describes the format of a stored date value of this platform. |
string | Gets the format string, as accepted by the date() function, that describes the format of a stored datetime value of this platform. |
string | getDateTimeTypeDeclarationSQL(array fieldDeclaration) Obtain DBMS specific SQL to be used to create datetime fields in statements like CREATE TABLE |
string | getDateTypeDeclarationSQL(array fieldDeclaration) Obtain DBMS specific SQL to be used to create date fields in statements like CREATE TABLE. |
string | getDecimalTypeDeclarationSQL(array columnDef) Gets the SQL snippet that declares a floating point column of arbitrary precision. |
integer | getDefaultTransactionIsolationLevel() Gets the default transaction isolation level of the platform. |
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 | getDropConstraintSQL(\Doctrine\DBAL\Schema\Constraint constraint, string|Table table) Get drop constraint sql |
void | getDropDatabaseSQL(mixed database) |
string | getDropForeignKeySQL(ForeignKeyConstraint|string foreignKey, Table|string table) |
string | getDropIndexSQL(mixed index, string|Table table, Index|string name) Drop index from a table |
void | getDropSequenceSQL(mixed sequence) |
string | getDropTableSQL(Table|string table) Drop a Table |
void | getDropViewSQL(mixed name) |
string | getEmptyIdentityInsertSQL(string tableName, string identifierColumnName) Get the insert sql for an empty insert statement |
void | |
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 | getForeignKeyDeclarationSQL(mixed foreignKey, array definition) 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. |
void | getForeignKeyReferentialActionSQL(string action, string foreign) returns given referential action in uppercase if valid, otherwise throws an exception |
string | Gets the character used for identifier quoting. |
void | |
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 | 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 | getIndexFieldDeclarationListSQL(mixed fields) getIndexFieldDeclarationList Obtain DBMS specific SQL code portion needed to set an index declaration to be used in statements like CREATE TABLE. |
abstract string | getIntegerTypeDeclarationSQL(array columnDef) Gets the SQL snippet that declares a 4 byte integer column. |
string | getIsNotNullExpression(string expression) Returns SQL that checks if a expression is not null. |
string | getIsNullExpression(string expression) Returns SQL that checks if a expression is null. |
string | getLengthExpression(mixed column, string expression1, string expression2) Returns the length of a text field. |
void | |
void | getListSequencesSQL(mixed database) |
void | getListTableColumnsSQL(mixed table) |
void | getListTableConstraintsSQL(mixed table) |
void | getListTableForeignKeysSQL(mixed table) |
void | getListTableIndexesSQL(mixed table) |
void | |
void | |
string | getListViewsSQL(string database) Get the SQL to list all views of a database or user. |
integer | getLocateExpression(string str, string substr, mixed startPos, int pos) returns the position of the first occurrence of substring $substr in string $str |
string | getLowerExpression(string str) lower Returns the string $str with all characters changed to lowercase according to the current character set mapping. |
string | getLtrimExpression(string str) ltrim returns the string $str with leading space characters removed |
string | getMaxExpression(string column) Returns the highest value of a column |
int | Maximum length of any given databse identifier, like tables or column names. |
string | getMd5Expression(mixed column) Returns the md5 sum of a field. |
string | getMinExpression(string column) Returns the lowest value of a column |
string | getModExpression(string expression1, string expression2) Returns the remainder of the division operation $expression1 / $expression2. |
abstract string | getName() Gets the name of the platform. |
string | getNotExpression(mixed expression) Returns the SQL for a logical not. |
string | Returns the current system date. |
void | |
string | Returns the regular expression operator. |
string | getRoundExpression(mixed column, mixed decimals, string expression1, string expression2) Rounds a numeric field to the number of decimals specified. |
string | getRtrimExpression(string str) rtrim returns the string $str with proceeding space characters removed |
string | getSQLResultCasing(string column) Gets the character casing of a column in an SQL result set of this platform. |
void | getSequenceNextValSQL(mixed sequenceName) |
string | getSetCharsetSQL(string charset) Gets the SQL statement specific for the platform to set the charset. |
void | getSetTransactionIsolationSQL(integer level) Get sql to set the transaction isolation level |
string | Get sql query to show a list of database. |
void | getSinExpression(mixed value) |
abstract string | getSmallIntTypeDeclarationSQL(array columnDef) Gets the SQL snippet that declares a 2 byte integer column. |
string | Gets the string portion that ends an SQL comment. |
string | Gets the string portion that starts an SQL comment. |
string | getSubstringExpression(string value, integer from, integer len) return string to call a function to get a substring inside an SQL statementNote: Not SQL92, but common functionality. |
string | getSumExpression(string column) Returns the total sum of a column |
string | A method to return the required SQL string that fits between CREATE ... |
string | Gets the format string, as accepted by the date() function, that describes the format of a stored time value of this platform. |
string | getTimeTypeDeclarationSQL(array fieldDeclaration) Obtain DBMS specific SQL to be used to create time fields in statements like CREATE TABLE. |
string | getTrimExpression(string str, int pos, string char) Trim a string, leading/trailing/both and with a given char which defaults to space. |
string | getTruncateTableSQL(string tableName, bool cascade) Generate a Truncate Table SQL statement for a given 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 | 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 | getUpperExpression(string str) upper Returns the string $str with all characters changed to uppercase according to the current character set mapping. |
integer | Gets the maximum length of a varchar field. |
abstract void | getVarcharTypeDeclarationSQL(array field) Gets the SQL snippet used to declare a VARCHAR column type. |
array | Gets all SQL wildcard characters of the platform. |
void | modifyLimitQuery(mixed query, mixed limit, mixed offset) |
boolean | Whether the platform prefers identity columns (eg. |
boolean | Whether the platform prefers sequences for ID generation. |
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. |
void | |
boolean | supportsForeignKeyConstraints() Does the platform supports foreign key constraints? |
bool | Does this platform supports onUpdate in foreign key constraints? |
boolean | Whether the platform supports getting the affected rows of a recent update/delete type query. |
boolean | Whether the platform supports identity columns. |
boolean | Whether the platform supports indexes. |
boolean | Whether the platform supports primary key constraints. |
boolean | Whether the platform supports savepoints. |
boolean | Whether the platform supports database schemas. |
boolean | Whether the platform supports sequences. |
boolean | Whether the platform supports transactions. |
public final int CREATE_FOREIGNKEYS = 2
public final int CREATE_INDEXES = 1
public final int TRIM_BOTH = 3
public final int TRIM_LEADING = 1
public final int TRIM_TRAILING = 2
public final int $TRIM_UNSPECIFIED
public AbstractPlatform()
Constructor.
public void 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).
public bool createsExplicitIndexForForeignKeys()
public string fixSchemaElementName(mixed schemaElementName, string schemaName)
Makes any fixes to a name of a schema element (table, sequence, ...) that are required by restrictions of the platform, like a maximum length.
public void getAcosExpression(mixed value)
public string getAdvancedForeignKeyOptionsSQL(ForeignKeyConstraint foreignKey)
Return the FOREIGN KEY query section dealing with non-standard options as MATCH, INITIALLY DEFERRED, ON UPDATE, ...
public 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.
public string getAvgExpression(string column)
Returns the average value of a column
public 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().
public abstract string getBigIntTypeDeclarationSQL(array columnDef)
Gets the SQL snippet that declares an 8 byte integer column.
public abstract string getBooleanTypeDeclarationSQL(array columnDef)
Gets the SQL snippet that declares a boolean column.
public 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.
public abstract void getClobTypeDeclarationSQL(array field)
Gets the SQL snippet used to declare a CLOB column type.
public 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.
public 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.
public string getColumnDeclarationListSQL(array fields)
Get declaration of a number of fields in bulk
public 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.
public string getConcatExpression(string arg1,)
Returns a series of strings concatinated
concat() accepts an arbitrary number of parameters. Each parameter must contain an expression
public void getCosExpression(mixed value)
public 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.
public string getCreateConstraintSQL(Constraint constraint, string|Table table)
Gets the SQL to create a constraint on a table on this platform.
public void getCreateDatabaseSQL(mixed database)
public string getCreateForeignKeySQL(ForeignKeyConstraint foreignKey, string|Table table)
Create a new foreign key
public string getCreateIndexSQL(Index index, string|Table table)
Gets the SQL to create an index on a table on this platform.
public void getCreateSequenceSQL(\Doctrine\DBAL\Schema\Sequence sequence)
Gets the SQL to create a sequence on this platform.
public array getCreateTableSQL(string table, int createFlags)
Gets the SQL statement(s) to create a table with the specified name, columns and constraints on this platform.
public void getCreateTemporaryTableSnippetSQL()
public void getCreateViewSQL(mixed name, mixed sql)
public string getCurrentDateSQL()
Gets the SQL specific for the platform to get the current date.
public string getCurrentTimeSQL()
Gets the SQL specific for the platform to get the current time.
public string getCurrentTimestampSQL()
Gets the SQL specific for the platform to get the current timestamp
public string getCustomTypeDeclarationSQL(mixed 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.
public string getDateFormatString()
Gets the format string, as accepted by the date() function, that describes the format of a stored date value of this platform.
public string getDateTimeFormatString()
Gets the format string, as accepted by the date() function, that describes the format of a stored datetime value of this platform.
public string getDateTimeTypeDeclarationSQL(array fieldDeclaration)
Obtain DBMS specific SQL to be used to create datetime fields in statements like CREATE TABLE
public string getDateTypeDeclarationSQL(array fieldDeclaration)
Obtain DBMS specific SQL to be used to create date fields in statements like CREATE TABLE.
public string getDecimalTypeDeclarationSQL(array columnDef)
Gets the SQL snippet that declares a floating point column of arbitrary precision.
public integer getDefaultTransactionIsolationLevel()
Gets the default transaction isolation level of the platform.
public 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.
public string getDropConstraintSQL(\Doctrine\DBAL\Schema\Constraint constraint, string|Table table)
Get drop constraint sql
public void getDropDatabaseSQL(mixed database)
public string getDropForeignKeySQL(ForeignKeyConstraint|string foreignKey, Table|string table)
public string getDropIndexSQL(mixed index, string|Table table, Index|string name)
Drop index from a table
public void getDropSequenceSQL(mixed sequence)
public string getDropTableSQL(Table|string table)
Drop a Table
public void getDropViewSQL(mixed name)
public string getEmptyIdentityInsertSQL(string tableName, string identifierColumnName)
Get the insert sql for an empty insert statement
public void getForUpdateSql()
public 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.
public string getForeignKeyDeclarationSQL(mixed foreignKey, array definition)
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.
public void getForeignKeyReferentialActionSQL(string action, string foreign)
returns given referential action in uppercase if valid, otherwise throws an exception
public string getIdentifierQuoteCharacter()
Gets the character used for identifier quoting.
public void getIdentityColumnNullInsertSQL()
public 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.
public 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.
public string getIndexFieldDeclarationListSQL(mixed fields)
getIndexFieldDeclarationList Obtain DBMS specific SQL code portion needed to set an index declaration to be used in statements like CREATE TABLE.
public abstract string getIntegerTypeDeclarationSQL(array columnDef)
Gets the SQL snippet that declares a 4 byte integer column.
public string getIsNotNullExpression(string expression)
Returns SQL that checks if a expression is not null.
public string getIsNullExpression(string expression)
Returns SQL that checks if a expression is null.
public string getLengthExpression(mixed column, string expression1, string expression2)
Returns the length of a text field.
public void getListDatabasesSQL()
public void getListSequencesSQL(mixed database)
public void getListTableColumnsSQL(mixed table)
public void getListTableConstraintsSQL(mixed table)
public void getListTableForeignKeysSQL(mixed table)
public void getListTableIndexesSQL(mixed table)
public void getListTablesSQL()
public void getListUsersSQL()
public string getListViewsSQL(string database)
Get the SQL to list all views of a database or user.
public integer getLocateExpression(string str, string substr, mixed startPos, int pos)
returns the position of the first occurrence of substring $substr in string $str
public string getLowerExpression(string str)
lower Returns the string $str with all characters changed to lowercase according to the current character set mapping.
public string getLtrimExpression(string str)
ltrim returns the string $str with leading space characters removed
public string getMaxExpression(string column)
Returns the highest value of a column
public int getMaxIdentifierLength()
Maximum length of any given databse identifier, like tables or column names.
public string getMd5Expression(mixed column)
Returns the md5 sum of a field.
Note: Not SQL92, but common functionality
public string getMinExpression(string column)
Returns the lowest value of a column
public string getModExpression(string expression1, string expression2)
Returns the remainder of the division operation $expression1 / $expression2.
public abstract string getName()
Gets the name of the platform.
public string getNotExpression(mixed 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'));
public string getNowExpression()
Returns the current system date.
public void getPiExpression()
public string getRegexpExpression()
Returns the regular expression operator.
public string getRoundExpression(mixed column, mixed decimals, string expression1, string expression2)
Rounds a numeric field to the number of decimals specified.
public string getRtrimExpression(string str)
rtrim returns the string $str with proceeding space characters removed
public string getSQLResultCasing(string column)
Gets the character casing of a column in an SQL result set of this platform.
public void getSequenceNextValSQL(mixed sequenceName)
public string getSetCharsetSQL(string charset)
Gets the SQL statement specific for the platform to set the charset.
This function is MySQL specific and required by \Doctrine\DBAL\Connection::setCharset($charset)
public void getSetTransactionIsolationSQL(integer level)
Get sql to set the transaction isolation level
public string getShowDatabasesSQL()
Get sql query to show a list of database.
public void getSinExpression(mixed value)
public abstract string getSmallIntTypeDeclarationSQL(array columnDef)
Gets the SQL snippet that declares a 2 byte integer column.
public string getSqlCommentEndString()
Gets the string portion that ends an SQL comment.
public string getSqlCommentStartString()
Gets the string portion that starts an SQL comment.
public string getSubstringExpression(string value, integer from, integer len)
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
public string getSumExpression(string column)
Returns the total sum of a column
public 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".
public string getTimeFormatString()
Gets the format string, as accepted by the date() function, that describes the format of a stored time value of this platform.
public string getTimeTypeDeclarationSQL(array fieldDeclaration)
Obtain DBMS specific SQL to be used to create time fields in statements like CREATE TABLE.
public string getTrimExpression(string str, int pos, string char)
Trim a string, leading/trailing/both and with a given char which defaults to space.
public string getTruncateTableSQL(string tableName, bool cascade)
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.
public 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.
public 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.
public string getUpperExpression(string str)
upper Returns the string $str with all characters changed to uppercase according to the current character set mapping.
public integer getVarcharMaxLength()
Gets the maximum length of a varchar field.
public abstract void getVarcharTypeDeclarationSQL(array field)
Gets the SQL snippet used to declare a VARCHAR column type.
public array getWildcards()
Gets all SQL wildcard characters of the platform.
public void modifyLimitQuery(mixed query, mixed limit, mixed offset)
public 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.
public boolean prefersSequences()
Whether the platform prefers sequences for ID generation. Subclasses should override this method to return TRUE if they prefer sequences.
public 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.
public void supportsAlterTable()
public boolean supportsForeignKeyConstraints()
Does the platform supports foreign key constraints?
public bool supportsForeignKeyOnUpdate()
Does this platform supports onUpdate in foreign key constraints?
public boolean supportsGettingAffectedRows()
Whether the platform supports getting the affected rows of a recent update/delete type query.
public 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.
public boolean supportsIndexes()
Whether the platform supports indexes.
public boolean supportsPrimaryConstraints()
Whether the platform supports primary key constraints.
public boolean supportsSavepoints()
Whether the platform supports savepoints.
public boolean supportsSchemas()
Whether the platform supports database schemas.
public boolean supportsSequences()
Whether the platform supports sequences.
public boolean supportsTransactions()
Whether the platform supports transactions.
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.