Allow a new column to be added at a specific position

This commit is contained in:
Kijin Sung 2017-10-13 17:47:38 +09:00
parent e22551b224
commit 91550131ac
2 changed files with 12 additions and 2 deletions

View file

@ -468,9 +468,10 @@ class DBCubrid extends DB
* @param int $size column size
* @param string|int $default default value
* @param boolean $notnull not null status, default value is false
* @param string $after_column
* @return void
*/
function addColumn($table_name, $column_name, $type = 'number', $size = '', $default = null, $notnull = FALSE)
function addColumn($table_name, $column_name, $type = 'number', $size = '', $default = null, $notnull = false, $after_column = false)
{
$type = strtoupper($this->column_type[$type]);
if($type == 'INTEGER')
@ -513,6 +514,10 @@ class DBCubrid extends DB
{
$query .= "not null ";
}
if($after_column)
{
$query .= sprintf(" after `%s` ", $after_column);
}
return $this->_query($query);
}

View file

@ -281,9 +281,10 @@ class DBMysql extends DB
* @param int $size column size
* @param string|int $default default value
* @param boolean $notnull not null status, default value is false
* @param string $after_column
* @return void
*/
function addColumn($table_name, $column_name, $type = 'number', $size = '', $default = null, $notnull = false)
function addColumn($table_name, $column_name, $type = 'number', $size = '', $default = null, $notnull = false, $after_column = false)
{
$type = $this->column_type[$type];
if(strtoupper($type) == 'INTEGER')
@ -308,6 +309,10 @@ class DBMysql extends DB
{
$query .= " not null ";
}
if($after_column)
{
$query .= sprintf(" after `%s` ", $after_column);
}
return $this->_query($query);
}