Implement modifyColumn() for MS SQL

This commit is contained in:
Kijin Sung 2014-08-11 12:21:53 +09:00
parent a0ab42d92d
commit ccae599b24

View file

@ -427,6 +427,46 @@ class DBMssql extends DB
$this->_query($query);
}
/**
* Modify a column
* @param string $table_name table name
* @param string $column_name column name
* @param string $type column type, default value is 'number'
* @param int $size column size
* @param string|int $default default value
* @param boolean $notnull not null status, default value is false
* @return bool
*/
function modifyColumn($table_name, $column_name, $type = 'number', $size = '', $default = '', $notnull = false)
{
$type = $this->column_type[$type];
if(strtoupper($type) == 'INTEGER')
{
$size = '';
}
$query = sprintf("alter table %s%s alter column %s ", $this->prefix, $table_name, $column_name);
if($size)
{
$query .= sprintf(" %s(%s) ", $type, $size);
}
else
{
$query .= sprintf(" %s ", $type);
}
if($default)
{
$query .= sprintf(" default '%s' ", $default);
}
if($notnull)
{
$query .= " not null ";
}
return $this->_query($query) ? true : false;
}
/**
* Check column exist status of the table
* @param string $table_name table name
@ -448,7 +488,7 @@ class DBMssql extends DB
}
return true;
}
/**
* Get information about a column
* @param string $table_name table name