MetaModels\Helper\TableManipulation::createColumn PHP Метод

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
    public static function createColumn($strTableName, $strColumnName, $strType, $blnAllowSystemCol = false)
    {
        self::checkColumnDoesNotExist($strTableName, $strColumnName, $blnAllowSystemCol);
        self::getDB()->execute(sprintf(self::STATEMENT_CREATE_COLUMN, $strTableName, $strColumnName, $strType));
    }

Usage Example

Пример #1
0
 /**
  * Creates the underlying database structure for this field.
  *
  * You have to override this function in field types, when you want to have multi column structure etc.
  *
  * @return void
  */
 public function createColumn()
 {
     if ($this->getColName()) {
         TableManipulation::createColumn($this->getMetaModel()->getTableName(), $this->getColName(), $this->getSQLDataType());
     }
 }