Propel 2 API
Class

Propel\Generator\Platform\MysqlPlatform

class MysqlPlatform extends DefaultPlatform

MySql PlatformInterface implementation.

Methods

__construct(ConnectionInterface $con = null)

Default constructor.

from DefaultPlatform
getObjectBuilderClass($type)

from DefaultPlatform
setConnection(ConnectionInterface $con = null)

Sets the database connection to use for this Platform class.

from DefaultPlatform
ConnectionInterface getConnection()

Returns the database connection to use for this Platform class.

from DefaultPlatform
string|null getBuilderClass($type $type)

Returns a platform specific builder class if exists.

from DefaultPlatform
setGeneratorConfig(GeneratorConfigInterface $generatorConfig)

Sets the GeneratorConfigInterface to use in the parsing.

string getDatabaseType()

Returns the short name of the database type that this platform represents.

from DefaultPlatform
int getMaxColumnNameLength()

Returns the max column length supported by the db.

string getNativeIdMethod()

Returns the native IdMethod (sequence|identity)

from DefaultPlatform
isNativeIdMethodAutoIncrement()

from DefaultPlatform
Domain getDomainForType(string $mappingType)

Returns the database specific domain for a mapping type.

from DefaultPlatform
string. getNullString($notNull)

Returns the NOT NULL string for the configured RDBMS.

from DefaultPlatform
string. getAutoIncrement()

Returns the auto increment strategy for the configured RDBMS.

string getSequenceName(Table $table)

Returns the name to use for creating a table sequence.

from DefaultPlatform
string getAddTablesDDL(Database $database)

Returns the DDL SQL to add the tables of a database together with index and foreign keys

string getBeginDDL()

Gets the requests to execute at the beginning of a DDL file

string getEndDDL()

Gets the requests to execute at the end of a DDL file

string getDropTableDDL(Table $table)

Builds the DDL SQL to drop a table

string getAddTableDDL(Table $table)

Builds the DDL SQL to add a table without index and foreign keys

string getColumnDDL(Column $col)

Builds the DDL SQL for a Column object.

string getColumnDefaultValueDDL(Column $col)

Returns the SQL for the default value of a Column object

from DefaultPlatform
string getColumnListDDL(Column[]|string[] $columns, string $delimiter = ',')

Creates a delimiter-delimited string list of column names, quoted using quoteIdentifier().

from DefaultPlatform
string getPrimaryKeyName(Table $table)

Returns the name of a table primary key.

from DefaultPlatform
string getPrimaryKeyDDL(Table $table)

Returns the SQL for the primary key of a Table object

string getDropPrimaryKeyDDL(Table $table)

Builds the DDL SQL to drop the primary key of a table.

string getAddPrimaryKeyDDL(Table $table)

Returns the DDL SQL to add the primary key of a table.

from DefaultPlatform
string getAddIndicesDDL(Table $table)

Returns the DDL SQL to add the indices of a table.

from DefaultPlatform
string getAddIndexDDL(Index $index)

Builds the DDL SQL to add an Index.

string getDropIndexDDL(Index $index)

Builds the DDL SQL to drop an Index.

string getIndexDDL(Index $index)

Builds the DDL SQL for an Index object.

string getUniqueDDL(Unique $unique)

Builds the DDL SQL for a Unique constraint object.

string getAddForeignKeysDDL(Table $table)

Builds the DDL SQL to add the foreign keys of a table.

from DefaultPlatform
string getAddForeignKeyDDL(ForeignKey $fk)

Builds the DDL SQL to add a foreign key.

string getDropForeignKeyDDL(ForeignKey $fk)

Builds the DDL SQL to drop a foreign key.

string getForeignKeyDDL(ForeignKey $fk)

Builds the DDL SQL for a ForeignKey object.

getCommentLineDDL($comment)

from DefaultPlatform
getCommentBlockDDL($comment)

string getModifyDatabaseDDL(DatabaseDiff $databaseDiff)

Builds the DDL SQL to modify a database based on a DatabaseDiff instance

string getRenameTableDDL($fromTableName, $toTableName)

Builds the DDL SQL to rename a table

string getModifyTableDDL(TableDiff $tableDiff)

Builds the DDL SQL to alter a table based on a TableDiff instance

from DefaultPlatform
string getModifyTableColumnsDDL(TableDiff $tableDiff)

Builds the DDL SQL to alter a table based on a TableDiff instance

from DefaultPlatform
string getModifyTablePrimaryKeyDDL(TableDiff $tableDiff)

Builds the DDL SQL to alter a table's primary key based on a TableDiff instance

from DefaultPlatform
string getModifyTableIndicesDDL(TableDiff $tableDiff)

Builds the DDL SQL to alter a table's indices based on a TableDiff instance

from DefaultPlatform
string getModifyTableForeignKeysDDL(TableDiff $tableDiff)

Builds the DDL SQL to alter a table's foreign keys based on a TableDiff instance

from DefaultPlatform
string getRemoveColumnDDL(Column $column)

Builds the DDL SQL to remove a column

string getRenameColumnDDL($fromColumn, $toColumn)

Builds the DDL SQL to rename a column

string getModifyColumnDDL(ColumnDiff $columnDiff)

Builds the DDL SQL to modify a column

string getModifyColumnsDDL($columnDiffs)

Builds the DDL SQL to modify a list of columns

string getAddColumnDDL(Column $column)

Builds the DDL SQL to remove a column

from DefaultPlatform
string getAddColumnsDDL($columns)

Builds the DDL SQL to remove a list of columns

from DefaultPlatform
boolean hasSize(string $sqlType)

Returns if the RDBMS-specific SQL type has a size attribute.

boolean hasScale(string $sqlType)

Returns if the RDBMS-specific SQL type has a scale attribute.

from DefaultPlatform
string quote(string $text)

Quote and escape needed characters in the string for underlying RDBMS.

from DefaultPlatform
string quoteIdentifier(string $text)

MySQL documentation says that identifiers cannot contain '.'.

setIdentifierQuoting($enabled = true)

from DefaultPlatform
getIdentifierQuoting()

from DefaultPlatform
boolean supportsNativeDeleteTrigger()

Whether RDBMS supports native ON DELETE triggers (e.g.

boolean supportsInsertNullPk()

Whether RDBMS supports INSERT null values in autoincremented primary keys

from DefaultPlatform
boolean hasStreamBlobImpl()

Whether the underlying PDO driver for this platform returns BLOB columns as streams (instead of strings).

from DefaultPlatform
boolean supportsSchemas()

boolean supportsMigrations()

from DefaultPlatform
boolean supportsVarcharWithoutSize()

Whether RDBMS supports VARCHAR without explicit size

from DefaultPlatform
mixed getBooleanString($b)

Returns the Boolean value for the RDBMS.

from DefaultPlatform
getPhpArrayString($stringValue)

from DefaultPlatform
string getTimestampFormatter()

Gets the preferred timestamp formatter for setting date/time values.

string getTimeFormatter()

Gets the preferred time formatter for setting date/time values.

from DefaultPlatform
string getDateFormatter()

Gets the preferred date formatter for setting date/time values.

from DefaultPlatform
getColumnBindingPHP($column, $identifier, $columnValueAccessor, $tab = ' ')

Get the PHP snippet for binding a value to a column.

getIdentifierPhp($columnValueMutator, $connectionVariableName = '$con', $sequenceName = '', $tab = ' ')

Get the PHP snippet for getting a Pk from the database.

from DefaultPlatform
setTableEngineKeyword(string $tableEngineKeyword)

Setter for the tableEngineKeyword property

string getTableEngineKeyword()

Getter for the tableEngineKeyword property

setDefaultTableEngine(string $defaultTableEngine)

Setter for the defaultTableEngine property

string getDefaultTableEngine()

Getter for the defaultTableEngine property

supportsForeignKeys(Table $table)

string getChangeColumnDDL($fromColumn, $toColumn)

Builds the DDL SQL to change a column

string disconnectedEscapeText(string $text)

Escape the string for RDBMS.

Details

in DefaultPlatform at line 59
public __construct(ConnectionInterface $con = null)

Default constructor.

Parameters

ConnectionInterface $con Optional database connection to use in this platform.

in DefaultPlatform at line 68
public getObjectBuilderClass($type)

Parameters

$type

in DefaultPlatform at line 78
public setConnection(ConnectionInterface $con = null)

Sets the database connection to use for this Platform class.

Parameters

ConnectionInterface $con Database connection to use in this platform.

in DefaultPlatform at line 88
public ConnectionInterface getConnection()

Returns the database connection to use for this Platform class.

Return Value

ConnectionInterface The database connection or NULL if none has been set.

in DefaultPlatform at line 100
public string|null getBuilderClass($type $type)

Returns a platform specific builder class if exists.

Parameters

$type $type

Return Value

string|null Returns null if no platform specified builder class exists.

at line 63
public setGeneratorConfig(GeneratorConfigInterface $generatorConfig)

Sets the GeneratorConfigInterface to use in the parsing.

Parameters

GeneratorConfigInterface $generatorConfig

in DefaultPlatform at line 167
public string getDatabaseType()

Returns the short name of the database type that this platform represents.

For example MysqlPlatform->getDatabaseType() returns 'mysql'.

Return Value

string

at line 118
public int getMaxColumnNameLength()

Returns the max column length supported by the db.

Return Value

int The max column length

in DefaultPlatform at line 191
public string getNativeIdMethod()

Returns the native IdMethod (sequence|identity)

Return Value

string The native IdMethod (PlatformInterface:IDENTITY, PlatformInterface::SEQUENCE).

in DefaultPlatform at line 196
public isNativeIdMethodAutoIncrement()

in DefaultPlatform at line 207
public Domain getDomainForType(string $mappingType)

Returns the database specific domain for a mapping type.

Parameters

string $mappingType

Return Value

Domain The db specific domain.

in DefaultPlatform at line 221
public string. getNullString($notNull)

Returns the NOT NULL string for the configured RDBMS.

Parameters

$notNull

Return Value

string. The RDBMS-specific SQL fragment for <code>NULL</code> or <code>NOT NULL</code>.

at line 113
public string. getAutoIncrement()

Returns the auto increment strategy for the configured RDBMS.

Return Value

string. RDBMS-specific SQL fragment for autoincrement.

in DefaultPlatform at line 246
public string getSequenceName(Table $table)

Returns the name to use for creating a table sequence.

This will create a new name or use one specified in an
id-method-parameter tag, if specified.

Parameters

Table $table

Return Value

string

at line 142
public string getAddTablesDDL(Database $database)

Returns the DDL SQL to add the tables of a database together with index and foreign keys

Parameters

Database $database

Return Value

string

at line 155
public string getBeginDDL()

Gets the requests to execute at the beginning of a DDL file

Return Value

string

at line 164
public string getEndDDL()

Gets the requests to execute at the end of a DDL file

Return Value

string

at line 317
public string getDropTableDDL(Table $table)

Builds the DDL SQL to drop a table

Parameters

Table $table

Return Value

string

at line 201
public string getAddTableDDL(Table $table)

Builds the DDL SQL to add a table without index and foreign keys

Parameters

Table $table

Return Value

string

at line 324
public string getColumnDDL(Column $col)

Builds the DDL SQL for a Column object.

Parameters

Column $col

Return Value

string

in DefaultPlatform at line 393
public string getColumnDefaultValueDDL(Column $col)

Returns the SQL for the default value of a Column object

Parameters

Column $col

Return Value

string

in DefaultPlatform at line 436
public string getColumnListDDL(Column[]|string[] $columns, string $delimiter = ',')

Creates a delimiter-delimited string list of column names, quoted using quoteIdentifier().

Parameters

Column[]|string[] $columns
string $delimiter The delimiter to use in separating the column names.

Return Value

string

in DefaultPlatform at line 454
public string getPrimaryKeyName(Table $table)

Returns the name of a table primary key.

Parameters

Table $table

Return Value

string

at line 179
public string getPrimaryKeyDDL(Table $table)

Returns the SQL for the primary key of a Table object

Parameters

Table $table

Return Value

string

at line 419
public string getDropPrimaryKeyDDL(Table $table)

Builds the DDL SQL to drop the primary key of a table.

Parameters

Table $table

Return Value

string

in DefaultPlatform at line 497
public string getAddPrimaryKeyDDL(Table $table)

Returns the DDL SQL to add the primary key of a table.

Parameters

Table $table

Return Value

string

in DefaultPlatform at line 515
public string getAddIndicesDDL(Table $table)

Returns the DDL SQL to add the indices of a table.

Parameters

Table $table

Return Value

string

at line 436
public string getAddIndexDDL(Index $index)

Builds the DDL SQL to add an Index.

Parameters

Index $index

Return Value

string

at line 456
public string getDropIndexDDL(Index $index)

Builds the DDL SQL to drop an Index.

Parameters

Index $index

Return Value

string

at line 472
public string getIndexDDL(Index $index)

Builds the DDL SQL for an Index object.

Parameters

Index $index

Return Value

string

at line 494
public string getUniqueDDL(Unique $unique)

Builds the DDL SQL for a Unique constraint object.

Parameters

Unique $unique

Return Value

string

in DefaultPlatform at line 594
public string getAddForeignKeysDDL(Table $table)

Builds the DDL SQL to add the foreign keys of a table.

Parameters

Table $table

Return Value

string

at line 502
public string getAddForeignKeyDDL(ForeignKey $fk)

Builds the DDL SQL to add a foreign key.

Parameters

ForeignKey $fk

Return Value

string

at line 527
public string getDropForeignKeyDDL(ForeignKey $fk)

Builds the DDL SQL to drop a foreign key.

Parameters

ForeignKey $fk

Return Value

string

at line 518
public string getForeignKeyDDL(ForeignKey $fk)

Builds the DDL SQL for a ForeignKey object.

Parameters

ForeignKey $fk

Return Value

string

in DefaultPlatform at line 676
public getCommentLineDDL($comment)

Parameters

$comment

at line 543
public getCommentBlockDDL($comment)

Parameters

$comment

at line 560
public string getModifyDatabaseDDL(DatabaseDiff $databaseDiff)

Builds the DDL SQL to modify a database based on a DatabaseDiff instance

Parameters

DatabaseDiff $databaseDiff

Return Value

string

at line 589
public string getRenameTableDDL($fromTableName, $toTableName)

Builds the DDL SQL to rename a table

Parameters

$fromTableName
$toTableName

Return Value

string

in DefaultPlatform at line 753
public string getModifyTableDDL(TableDiff $tableDiff)

Builds the DDL SQL to alter a table based on a TableDiff instance

Parameters

TableDiff $tableDiff

Return Value

string

in DefaultPlatform at line 818
public string getModifyTableColumnsDDL(TableDiff $tableDiff)

Builds the DDL SQL to alter a table based on a TableDiff instance

Parameters

TableDiff $tableDiff

Return Value

string

in DefaultPlatform at line 847
public string getModifyTablePrimaryKeyDDL(TableDiff $tableDiff)

Builds the DDL SQL to alter a table's primary key based on a TableDiff instance

Parameters

TableDiff $tableDiff

Return Value

string

in DefaultPlatform at line 865
public string getModifyTableIndicesDDL(TableDiff $tableDiff)

Builds the DDL SQL to alter a table's indices based on a TableDiff instance

Parameters

TableDiff $tableDiff

Return Value

string

in DefaultPlatform at line 892
public string getModifyTableForeignKeysDDL(TableDiff $tableDiff)

Builds the DDL SQL to alter a table's foreign keys based on a TableDiff instance

Parameters

TableDiff $tableDiff

Return Value

string

at line 606
public string getRemoveColumnDDL(Column $column)

Builds the DDL SQL to remove a column

Parameters

Column $column

Return Value

string

at line 622
public string getRenameColumnDDL($fromColumn, $toColumn)

Builds the DDL SQL to rename a column

Parameters

$fromColumn
$toColumn

Return Value

string

at line 632
public string getModifyColumnDDL(ColumnDiff $columnDiff)

Builds the DDL SQL to modify a column

Parameters

ColumnDiff $columnDiff

Return Value

string

at line 658
public string getModifyColumnsDDL($columnDiffs)

Builds the DDL SQL to modify a list of columns

Parameters

$columnDiffs

Return Value

string

in DefaultPlatform at line 1004
public string getAddColumnDDL(Column $column)

Builds the DDL SQL to remove a column

Parameters

Column $column

Return Value

string

in DefaultPlatform at line 1021
public string getAddColumnsDDL($columns)

Builds the DDL SQL to remove a list of columns

Parameters

$columns

Return Value

string

at line 676
public boolean hasSize(string $sqlType)

Returns if the RDBMS-specific SQL type has a size attribute.

Parameters

string $sqlType the SQL type

Return Value

boolean True if the type has a size attribute

in DefaultPlatform at line 1065
public boolean hasScale(string $sqlType)

Returns if the RDBMS-specific SQL type has a scale attribute.

Parameters

string $sqlType the SQL type

Return Value

boolean True if the type has a scale attribute

in DefaultPlatform at line 1075
public string quote(string $text)

Quote and escape needed characters in the string for underlying RDBMS.

Parameters

string $text

Return Value

string

at line 705
public string quoteIdentifier(string $text)

MySQL documentation says that identifiers cannot contain '.'.

Thus it
should be safe to split the string by '.' and quote each part individually
to allow for a <schema>.<table> or <table>.<column> syntax.

Parameters

string $text the identifier

Return Value

string the quoted identifier

in DefaultPlatform at line 1108
public setIdentifierQuoting($enabled = true)

Parameters

$enabled

in DefaultPlatform at line 1113
public getIdentifierQuoting()

at line 123
public boolean supportsNativeDeleteTrigger()

Whether RDBMS supports native ON DELETE triggers (e.g.

ON DELETE CASCADE).

Return Value

boolean

in DefaultPlatform at line 1131
public boolean supportsInsertNullPk()

Whether RDBMS supports INSERT null values in autoincremented primary keys

Return Value

boolean

in DefaultPlatform at line 1141
public boolean hasStreamBlobImpl()

Whether the underlying PDO driver for this platform returns BLOB columns as streams (instead of strings).

Return Value

boolean

at line 671
public boolean supportsSchemas()

Return Value

boolean

See also

Platform::supportsSchemas()

in DefaultPlatform at line 1157
public boolean supportsMigrations()

Return Value

boolean

See also

Platform::supportsMigrations()

in DefaultPlatform at line 1163
public boolean supportsVarcharWithoutSize()

Whether RDBMS supports VARCHAR without explicit size

Return Value

boolean

in DefaultPlatform at line 1179
public mixed getBooleanString($b)

Returns the Boolean value for the RDBMS.

This value should match the Boolean value that is set
when using Propel's PreparedStatement::setBoolean().

This function is used to set default column values when building
SQL.

Parameters

$b

Return Value

mixed

in DefaultPlatform at line 1197
public getPhpArrayString($stringValue)

Parameters

$stringValue

at line 710
public string getTimestampFormatter()

Gets the preferred timestamp formatter for setting date/time values.

Return Value

string

in DefaultPlatform at line 1230
public string getTimeFormatter()

Gets the preferred time formatter for setting date/time values.

Return Value

string

in DefaultPlatform at line 1239
public string getDateFormatter()

Gets the preferred date formatter for setting date/time values.

Return Value

string

at line 715
public getColumnBindingPHP($column, $identifier, $columnValueAccessor, $tab = ' ')

Get the PHP snippet for binding a value to a column.

Warning: duplicates logic from AdapterInterface::bindValue().
Any code modification here must be ported there.

Parameters

$column
$identifier
$columnValueAccessor
$tab

in DefaultPlatform at line 1284
public getIdentifierPhp($columnValueMutator, $connectionVariableName = '$con', $sequenceName = '', $tab = ' ')

Get the PHP snippet for getting a Pk from the database.

Warning: duplicates logic from AdapterInterface::getId().
Any code modification here must be ported there.

Typical output:
<code>
$this->id = $con->lastInsertId();
</code>

Parameters

$columnValueMutator
$connectionVariableName
$sequenceName
$tab

at line 78
public setTableEngineKeyword(string $tableEngineKeyword)

Setter for the tableEngineKeyword property

Parameters

string $tableEngineKeyword

at line 88
public string getTableEngineKeyword()

Getter for the tableEngineKeyword property

Return Value

string

at line 98
public setDefaultTableEngine(string $defaultTableEngine)

Setter for the defaultTableEngine property

Parameters

string $defaultTableEngine

at line 108
public string getDefaultTableEngine()

Getter for the defaultTableEngine property

Return Value

string

at line 128
public supportsForeignKeys(Table $table)

Parameters

Table $table

at line 641
public string getChangeColumnDDL($fromColumn, $toColumn)

Builds the DDL SQL to change a column

Parameters

$fromColumn
$toColumn

Return Value

string

at line 692
public string disconnectedEscapeText(string $text)

Escape the string for RDBMS.

Parameters

string $text

Return Value

string