mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-09 03:32:00 +09:00
Improve addColumn() and modifyColumn()
- 특정 컬럼 이후에 컬럼을 추가할 수 있도록 허용 - 모든 integer 타입의 size 속성을 무시 (tinyint 제외)
This commit is contained in:
parent
35b73eec0b
commit
32c9de472a
1 changed files with 12 additions and 6 deletions
|
|
@ -467,10 +467,11 @@ class DBMySQL extends DB
|
||||||
* @param boolean $notnull not null status, default value is false
|
* @param boolean $notnull not null status, default value is false
|
||||||
* @return void
|
* @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 = null)
|
||||||
{
|
{
|
||||||
$type = $this->column_type[$type];
|
$type = strtolower($type);
|
||||||
if(strtoupper($type) == 'INTEGER')
|
$type = isset($this->column_type[$type]) ? $this->column_type[$type] : $type;
|
||||||
|
if(in_array($type, ['integer', 'int', 'bigint', 'smallint']))
|
||||||
{
|
{
|
||||||
$size = '';
|
$size = '';
|
||||||
}
|
}
|
||||||
|
|
@ -492,6 +493,10 @@ class DBMySQL extends DB
|
||||||
{
|
{
|
||||||
$query .= " NOT NULL ";
|
$query .= " NOT NULL ";
|
||||||
}
|
}
|
||||||
|
if($after_column)
|
||||||
|
{
|
||||||
|
$query .= sprintf(" AFTER `%s` ", $after_column);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->_query($query);
|
return $this->_query($query);
|
||||||
}
|
}
|
||||||
|
|
@ -520,8 +525,9 @@ class DBMySQL extends DB
|
||||||
*/
|
*/
|
||||||
function modifyColumn($table_name, $column_name, $type = 'number', $size = '', $default = '', $notnull = false)
|
function modifyColumn($table_name, $column_name, $type = 'number', $size = '', $default = '', $notnull = false)
|
||||||
{
|
{
|
||||||
$type = $this->column_type[$type];
|
$type = strtolower($type);
|
||||||
if(strtoupper($type) == 'INTEGER')
|
$type = isset($this->column_type[$type]) ? $this->column_type[$type] : $type;
|
||||||
|
if(in_array($type, ['integer', 'int', 'bigint', 'smallint']))
|
||||||
{
|
{
|
||||||
$size = '';
|
$size = '';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue