MysqlSchema
- Type
- Class
- Namespace
- Craft
- Inherits
- Craft\MysqlSchema » CMysqlSchema (opens new window) » CDbSchema (opens new window) » CComponent (opens new window)
- Since
- 1.0
Class MysqlSchema
See also http://craftcms.com
View source (opens new window)
# Public Properties
| Property | Description |
|---|---|
| $columnTypes (opens new window) | array (opens new window) – The abstract column types mapped to physical column types. |
| $maxObjectNameLength | integer (opens new window) – The maximum length that objects' names can be. |
# $maxObjectNameLength
The maximum length that objects' names can be.
Signature
public integer $maxObjectNameLength = 64
# Public Methods
| Method | Description |
|---|---|
| __call() (opens new window) | Calls the named method which is not a class method. |
| __construct() | Constructor. |
| __get() (opens new window) | Returns a property value, an event handler list or a behavior based on its name. |
| __isset() (opens new window) | Checks if a property value is null. |
| __set() (opens new window) | Sets value of a component property. |
| __unset() (opens new window) | Sets a component property to be null. |
| addColumn() (opens new window) | Builds a SQL statement for adding a new DB column. |
| addColumnAfter() | |
| addColumnBefore() | |
| addColumnFirst() | |
| addForeignKey() (opens new window) | Builds a SQL statement for adding a foreign key constraint to an existing table. |
| addPrimaryKey() (opens new window) | Builds a SQL statement for adding a primary key constraint to an existing table. |
| alterColumn() | |
| asa() (opens new window) | Returns the named behavior object. |
| attachBehavior() (opens new window) | Attaches a behavior to this component. |
| attachBehaviors() (opens new window) | Attaches a list of behaviors to the component. |
| attachEventHandler() (opens new window) | Attaches an event handler to an event. |
| canGetProperty() (opens new window) | Determines whether a property can be read. |
| canSetProperty() (opens new window) | Determines whether a property can be set. |
| checkIntegrity() (opens new window) | Enables or disables integrity check. |
| compareTableNames() (opens new window) | Compares two table names. |
| createIndex() (opens new window) | Builds a SQL statement for creating a new index. |
| createTable() | |
| detachBehavior() (opens new window) | Detaches a behavior from the component. |
| detachBehaviors() (opens new window) | Detaches all behaviors from the component. |
| detachEventHandler() (opens new window) | Detaches an existing event handler. |
| disableBehavior() (opens new window) | Disables an attached behavior. |
| disableBehaviors() (opens new window) | Disables all behaviors attached to this component. |
| dropColumn() (opens new window) | Builds a SQL statement for dropping a DB column. |
| dropForeignKey() (opens new window) | Builds a SQL statement for dropping a foreign key constraint. |
| dropIndex() (opens new window) | Builds a SQL statement for dropping an index. |
| dropPrimaryKey() (opens new window) | Builds a SQL statement for removing a primary key constraint to an existing table. |
| dropTable() (opens new window) | Builds a SQL statement for dropping a DB table. |
| dropTableIfExists() | Builds a SQL statement for dropping a DB table if it exists. |
| enableBehavior() (opens new window) | Enables an attached behavior. |
| enableBehaviors() (opens new window) | Enables all behaviors attached to this component. |
| evaluateExpression() (opens new window) | Evaluates a PHP expression or callback under the context of this component. |
| getColumnType() (opens new window) | Converts an abstract column type into a physical column type. |
| getCommandBuilder() (opens new window) | |
| getDbConnection() (opens new window) | |
| getEventHandlers() (opens new window) | Returns the list of attached event handlers for an event. |
| getTable() (opens new window) | Obtains the metadata for the named table. |
| getTableNames() (opens new window) | Returns all table names in the database. |
| getTables() (opens new window) | Returns the metadata for all tables in the database. |
| hasEvent() (opens new window) | Determines whether an event is defined. |
| hasEventHandler() (opens new window) | Checks whether the named event has attached handlers. |
| hasProperty() (opens new window) | Determines whether a property is defined. |
| insertAll() | |
| orderByColumnValues() | Returns the SQL for ordering results by column values. |
| quoteColumnName() (opens new window) | Quotes a column name for use in a query. |
| quoteDatabaseName() | Quotes a database name for use in a query. |
| quoteSimpleColumnName() (opens new window) | Quotes a simple column name for use in a query. |
| quoteSimpleTableName() (opens new window) | Quotes a simple table name for use in a query. |
| quoteTableName() (opens new window) | Quotes a table name for use in a query. |
| raiseEvent() (opens new window) | Raises an event. |
| refresh() (opens new window) | Refreshes the schema. |
| renameColumn() (opens new window) | Builds a SQL statement for renaming a column. |
| renameTable() (opens new window) | Builds a SQL statement for renaming a DB table. |
| replace() | Returns the SQL for finding/replacing text. |
| resetSequence() (opens new window) | Resets the sequence value of a table's primary key. |
| truncateTable() (opens new window) | Builds a SQL statement for truncating a DB table. |
# __construct()
Constructor.
View source (opens new window)
Arguments
$conn(CDbConnection (opens new window)) – The database connection.
Signature
public void __construct ( $conn )
# addColumnAfter()
Signature
public string addColumnAfter ( $table, $column, $type, $after )
# addColumnBefore()
Signature
public string addColumnBefore ( $table, $column, $type, $before )
# addColumnFirst()
Signature
public string addColumnFirst ( $table, $column, $type )
# alterColumn()
View source (opens new window)
Arguments
$table(string (opens new window))$column(string (opens new window))$type(string (opens new window))$newName(mixed)$after(mixed)
Returns
Signature
public string alterColumn ( $table, $column, $type, $newName = null, $after = null )
# createTable()
View source (opens new window)
Arguments
$table(string (opens new window)) – The name of the table (including prefix, or wrapped in " and ").$columns(array (opens new window)) – An array of columns.$options(string (opens new window)) – Any additional SQL to append to the end of the query.$engine(string (opens new window)) – The engine the table should use ("InnoDb" or "MyISAM"). Default is "InnoDb".
Returns
string (opens new window) – The full SQL for creating a table.
Signature
public string createTable ( $table, $columns, $options = null, $engine = 'InnoDb' )
# dropTableIfExists()
Builds a SQL statement for dropping a DB table if it exists.
View source (opens new window)
Arguments
$table(string (opens new window))
Returns
Signature
public string dropTableIfExists ( $table )
# insertAll()
Signature
public mixed insertAll ( $table, $columns, $rows )
# orderByColumnValues()
Returns the SQL for ordering results by column values.
View source (opens new window)
Arguments
$column(string (opens new window))$values(array (opens new window))
Returns
Signature
public string orderByColumnValues ( $column, $values )
# quoteDatabaseName()
Signature
public string quoteDatabaseName ( $name )
# replace()
Returns the SQL for finding/replacing text.
View source (opens new window)
Arguments
$table(string (opens new window))$column(string (opens new window))$find(string (opens new window))$replace(string (opens new window))
Returns
Signature
public array replace ( $table, $column, $find, $replace )
# Protected Methods
| Method | Description |
|---|---|
| createColumn() (opens new window) | Creates a table column. |
| createCommandBuilder() (opens new window) | Creates a command builder for the database. |
| findColumns() (opens new window) | Collects the table column metadata. |
| findConstraints() (opens new window) | Collects the foreign key column details for the given table. |
| findTableNames() | Returns all table names in the database which start with the tablePrefix. |
| getServerVersion() (opens new window) | |
| loadTable() (opens new window) | Loads the metadata for the specified table. |
| resolveTableNames() (opens new window) | Generates various kinds of table names. |
# findTableNames()
Returns all table names in the database which start with the tablePrefix.
View source (opens new window)
Arguments
$schema(string (opens new window))
Returns
Signature
protected string findTableNames ( $schema = null )