PHP Класс MetaModels\Helper\TableManipulation

Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$reservedWords string[] List of reserved MySQL identifiers.
$systemColumns string[] When you alter this, ensure to also change @link{TableManipulation::STATEMENT_CREATE_TABLE} above.

Открытые методы

Метод Описание
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.

Защищенные методы

Метод Описание
getDB ( ) : Database Returns the Contao database instance to use.

Описание методов

addIndex() публичный статический метод

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.
Результат void

checkColumnDoesNotExist() публичный статический метод

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.
Результат void

checkColumnExists() публичный статический метод

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.
Результат void

checkColumnName() публичный статический метод

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.
Результат void

checkTableDoesNotExist() публичный статический метод

Ensures that the given table does not exist.
public static checkTableDoesNotExist ( string $strTableName ) : void
$strTableName string The table name to check.
Результат void

checkTableExists() публичный статический метод

Checks whether the given table exists.
public static checkTableExists ( string $strTableName ) : void
$strTableName string The table name to check.
Результат void

checkTablename() публичный статический метод

Checks whether the given table name is valid.
public static checkTablename ( string $strTableName ) : void
$strTableName string The table name to check.
Результат void

createColumn() публичный статический метод

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.
Результат void

createTable() публичный статический метод

Creates a table with the given name.
public static createTable ( string $strTableName ) : void
$strTableName string The name of the new table to create.
Результат void

deleteTable() публичный статический метод

Deletes the table with the given name.
public static deleteTable ( string $strTableName ) : void
$strTableName string The name of the new table to delete.
Результат void

dropColumn() публичный статический метод

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.
Результат void

getDB() защищенный статический метод

Returns the Contao database instance to use.
protected static getDB ( ) : Database
Результат Database the database instance.

isReservedWord() публичный статический метод

Test if the given word is a reserved MySQL word.
public static isReservedWord ( string $word ) : boolean
$word string The word to test.
Результат boolean

isSystemColumn() публичный статический метод

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.
Результат boolean true if the column is a system column, false otherwise.

isValidColumnName() публичный статический метод

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.
Результат boolean true if the column is a system column, false otherwise.

isValidMySQLIdentifier() публичный статический метод

Ensure that an identifier is valid in MySQL context.
public static isValidMySQLIdentifier ( string $strName ) : boolean
$strName string The identifier to check.
Результат boolean

isValidTablename() публичный статический метод

Checks whether the given table name is valid.
public static isValidTablename ( string $strTableName ) : boolean
$strTableName string The table name to check.
Результат boolean true if the table name is valid, false otherwise.

renameColumn() публичный статический метод

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.
Результат void

renameTable() публичный статический метод

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.
Результат void

setVariantSupport() публичный статический метод

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.
Результат void

Описание свойств

$reservedWords защищенное статическое свойство

List of reserved MySQL identifiers.
protected static string[] $reservedWords
Результат string[]

$systemColumns защищенное статическое свойство

When you alter this, ensure to also change @link{TableManipulation::STATEMENT_CREATE_TABLE} above.
protected static string[] $systemColumns
Результат string[]