skipColumn() public static method

public static skipColumn ( $tableDefinitions, $table, $colName, $type, $default, $null ) : boolean
$tableDefinitions
$table
$colName
$type
$default
$null
return boolean
Ejemplo n.º 1
0
 /**
  * @param $table
  * @param $colName
  * @param $type
  * @param $default
  * @param $null
  */
 protected function addModifyColumn($table, $colName, $type, $default, $null)
 {
     $existingColumns = $this->getValidTableColumns($table, false);
     $existingColName = null;
     // check for existing column case insensitive eg a rename from myInput to myinput
     $matchingExisting = preg_grep('/^' . preg_quote($colName, '/') . '$/i', $existingColumns);
     if (is_array($matchingExisting) && !empty($matchingExisting)) {
         $existingColName = current($matchingExisting);
     }
     if ($existingColName === null) {
         $this->db->query('ALTER TABLE `' . $table . '` ADD COLUMN `' . $colName . '` ' . $type . $default . ' ' . $null . ';');
         $this->resetValidTableColumnsCache($table);
     } else {
         if (!Object\ClassDefinition\Service::skipColumn($this->tableDefinitions, $table, $colName, $type, $default, $null)) {
             $this->db->query('ALTER TABLE `' . $table . '` CHANGE COLUMN `' . $existingColName . '` `' . $colName . '` ' . $type . $default . ' ' . $null . ';');
         }
     }
 }