From 91550131ac3315012ceae5c5fc5fc0e48c2240d4 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Fri, 13 Oct 2017 17:47:38 +0900 Subject: [PATCH] Allow a new column to be added at a specific position --- classes/db/DBCubrid.class.php | 7 ++++++- classes/db/DBMysql.class.php | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/classes/db/DBCubrid.class.php b/classes/db/DBCubrid.class.php index f010c9894..7aa6714ec 100644 --- a/classes/db/DBCubrid.class.php +++ b/classes/db/DBCubrid.class.php @@ -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); } diff --git a/classes/db/DBMysql.class.php b/classes/db/DBMysql.class.php index 000783bc4..4dbe384aa 100644 --- a/classes/db/DBMysql.class.php +++ b/classes/db/DBMysql.class.php @@ -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); }