PHP Class MetaModels\Helper\TableManipulation

Afficher le fichier Open project: metamodels/core Class Usage Examples

Protected Properties

Свойство Type Description
$reservedWords string[] List of reserved MySQL identifiers.
$systemColumns string[] When you alter this, ensure to also change @link{TableManipulation::STATEMENT_CREATE_TABLE} above.

Méthodes publiques

Méthode Description
addIndex ( string $strTableName, string $strIndexType, string $strColName ) : void Add a index to given tablename for specified columnname
checkColumnDoesNotExist ( string $strTableName, string $strColName, boolean $blnAllowSystemCol = false ) : void Checks whether the given column does not exist.
checkColumnExists ( string $strTableName, string $strColName, boolean $blnAllowSystemCol = false ) : void Checks whether the given table exists.
checkColumnName ( string $strColName, boolean $blnAllowSystemCol = false ) : void Checks whether the column with the given name is not a MetaModel system column and is a valid column name.
checkTableDoesNotExist ( string $strTableName ) : void Ensures that the given table does not exist.
checkTableExists ( string $strTableName ) : void Checks whether the given table exists.
checkTablename ( string $strTableName ) : void Checks whether the given table name is valid.
createColumn ( string $strTableName, string $strColumnName, string $strType, boolean $blnAllowSystemCol = false ) : void Add a column to a table.
createTable ( string $strTableName ) : void Creates a table with the given name.
deleteTable ( string $strTableName ) : void Deletes the table with the given name.
dropColumn ( string $strTableName, string $strColumnName, boolean $blnAllowSystemCol = false ) : void Delete a column from a table.
isReservedWord ( string $word ) : boolean Test if the given word is a reserved MySQL word.
isSystemColumn ( string $strColName ) : boolean Checks whether the column with the given name is a MetaModel system column.
isValidColumnName ( string $strColName ) : boolean Checks whether the column with the given name is a MetaModel system column.
isValidMySQLIdentifier ( string $strName ) : boolean Ensure that an identifier is valid in MySQL context.
isValidTablename ( string $strTableName ) : boolean Checks whether the given table name is valid.
renameColumn ( string $strTableName, string $strColumnName, string $strNewColumnName, string $strNewType, boolean $blnAllowSystemCol = false ) : void Rename a column and/or change it's type in a table.
renameTable ( string $strTableName, string $strNewTableName ) : void Renames a table with the given name to the given new name.
setVariantSupport ( string $strTableName, boolean $blnVariantSupport ) : void Enables or disables Variant support on a certain MetaModel table.

Méthodes protégées

Méthode Description
getDB ( ) : Database Returns the Contao database instance to use.

Method Details

addIndex() public static méthode

Add a index to given tablename for specified columnname
public static addIndex ( string $strTableName, string $strIndexType, string $strColName ) : void
$strTableName string The table name.
$strIndexType string The index type.
$strColName string The column name to add a index.
Résultat void

checkColumnDoesNotExist() public static méthode

Checks whether the given column does not exist.
public static checkColumnDoesNotExist ( string $strTableName, string $strColName, boolean $blnAllowSystemCol = false ) : void
$strTableName string The table name to check.
$strColName string The column name to check.
$blnAllowSystemCol boolean If this is set to true, no system column name checking will be applied.
Résultat void

checkColumnExists() public static méthode

Checks whether the given table exists.
public static checkColumnExists ( string $strTableName, string $strColName, boolean $blnAllowSystemCol = false ) : void
$strTableName string The table name to check.
$strColName string The column name to check.
$blnAllowSystemCol boolean If this is set to true, no system column name checking will be applied.
Résultat void

checkColumnName() public static méthode

If there is any problem, an Exception is raised, stating the nature of the error in the Exception message.
public static checkColumnName ( string $strColName, boolean $blnAllowSystemCol = false ) : void
$strColName string The name of the column.
$blnAllowSystemCol boolean If this is set to true, no system column name checking will be applied.
Résultat void

checkTableDoesNotExist() public static méthode

Ensures that the given table does not exist.
public static checkTableDoesNotExist ( string $strTableName ) : void
$strTableName string The table name to check.
Résultat void

checkTableExists() public static méthode

Checks whether the given table exists.
public static checkTableExists ( string $strTableName ) : void
$strTableName string The table name to check.
Résultat void

checkTablename() public static méthode

Checks whether the given table name is valid.
public static checkTablename ( string $strTableName ) : void
$strTableName string The table name to check.
Résultat void

createColumn() public static méthode

Throws Exception if the table does not exist, the column name is invalid or the column already exists.
public static createColumn ( string $strTableName, string $strColumnName, string $strType, boolean $blnAllowSystemCol = false ) : void
$strTableName string The name of the table to add the column to.
$strColumnName string The name of the new column.
$strType string The SQL type notation of the new column.
$blnAllowSystemCol boolean If this is set to true, no system column name checking will be applied.
Résultat void

createTable() public static méthode

Creates a table with the given name.
public static createTable ( string $strTableName ) : void
$strTableName string The name of the new table to create.
Résultat void

deleteTable() public static méthode

Deletes the table with the given name.
public static deleteTable ( string $strTableName ) : void
$strTableName string The name of the new table to delete.
Résultat void

dropColumn() public static méthode

Throws Exception if the table does not exist, the column name is invalid or the column does not exist.
public static dropColumn ( string $strTableName, string $strColumnName, boolean $blnAllowSystemCol = false ) : void
$strTableName string The name of the table the column is in.
$strColumnName string The name of the column to drop.
$blnAllowSystemCol boolean If this is set to true, no system column name checking will be applied.
Résultat void

getDB() protected static méthode

Returns the Contao database instance to use.
protected static getDB ( ) : Database
Résultat Database the database instance.

isReservedWord() public static méthode

Test if the given word is a reserved MySQL word.
public static isReservedWord ( string $word ) : boolean
$word string The word to test.
Résultat boolean

isSystemColumn() public static méthode

Checks whether the column with the given name is a MetaModel system column.
public static isSystemColumn ( string $strColName ) : boolean
$strColName string The name of the column.
Résultat boolean true if the column is a system column, false otherwise.

isValidColumnName() public static méthode

Checks whether the column with the given name is a MetaModel system column.
public static isValidColumnName ( string $strColName ) : boolean
$strColName string The name of the column.
Résultat boolean true if the column is a system column, false otherwise.

isValidMySQLIdentifier() public static méthode

Ensure that an identifier is valid in MySQL context.
public static isValidMySQLIdentifier ( string $strName ) : boolean
$strName string The identifier to check.
Résultat boolean

isValidTablename() public static méthode

Checks whether the given table name is valid.
public static isValidTablename ( string $strTableName ) : boolean
$strTableName string The table name to check.
Résultat boolean true if the table name is valid, false otherwise.

renameColumn() public static méthode

Throws Exception if the table does not exist, the column name is invalid or the column already exists.
public static renameColumn ( string $strTableName, string $strColumnName, string $strNewColumnName, string $strNewType, boolean $blnAllowSystemCol = false ) : void
$strTableName string The name of the table the column is in.
$strColumnName string The current name of the column to be renamed.
$strNewColumnName string The new name for the column.
$strNewType string The new SQL type notation of the column.
$blnAllowSystemCol boolean If this is set to true, no system column name checking will be applied.
Résultat void

renameTable() public static méthode

Renames a table with the given name to the given new name.
public static renameTable ( string $strTableName, string $strNewTableName ) : void
$strTableName string The name of the table to rename.
$strNewTableName string The name to which the table shall be renamed to.
Résultat void

setVariantSupport() public static méthode

Enables or disables Variant support on a certain MetaModel table.
public static setVariantSupport ( string $strTableName, boolean $blnVariantSupport ) : void
$strTableName string The table name of the MetaModel.
$blnVariantSupport boolean Flag if the support shall be turned on or off.
Résultat void

Property Details

$reservedWords protected_oe static_oe property

List of reserved MySQL identifiers.
protected static string[] $reservedWords
Résultat string[]

$systemColumns protected_oe static_oe property

When you alter this, ensure to also change @link{TableManipulation::STATEMENT_CREATE_TABLE} above.
protected static string[] $systemColumns
Résultat string[]