mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-07 02:31:40 +09:00
Implement modifyColumn() for MS SQL
This commit is contained in:
parent
a0ab42d92d
commit
ccae599b24
1 changed files with 41 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue