Module의 업데이트 필요 현황을 파악하고 업데이트를 할 수 있는 코드 추가. db의 column exists정보와 add column 기능 추가

git-svn-id: http://xe-core.googlecode.com/svn/trunk@1974 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
zero 2007-07-23 07:35:47 +00:00
parent cb2254ef96
commit a2eb5d62bf
38 changed files with 299 additions and 64 deletions

View file

@ -197,6 +197,41 @@
return true;
}
/**
* @brief 특정 테이블에 특정 column 추가
**/
function addColumn($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 add %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 ";
$this->_query($query);
}
/**
* @brief 특정 테이블의 column의 정보를 return
**/
function isColumnExists($table_name, $column_name) {
$query = sprintf("show fields from %s%s", $this->prefix, $table_name);
$result = $this->_query($query);
if($this->isError()) return;
$output = $this->_fetch($result);
if($output) {
$column_name = strtolower($column_name);
foreach($output as $key => $val) {
$name = strtolower($val->Field);
if($column_name == $name) return true;
}
}
return false;
}
/**
* @brief xml 받아서 테이블을 생성
**/