#19623705 DB 클래스 정리

1. DB 드라이버 생성방식 수정
2. $class_name, $class_file 이름 문자열 생성하는 부분 수정



git-svn-id: http://xe-core.googlecode.com/svn/sandbox@8184 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
taggon 2011-03-16 02:41:34 +00:00
parent 2c25d64fb5
commit 59bf3cbb83
10 changed files with 90 additions and 6 deletions

View file

@ -55,13 +55,13 @@
if(!$db_type && Context::isInstalled()) return new Object(-1, 'msg_db_not_setted');
if(!$GLOBALS['__DB__']) {
$class_name = sprintf("DB%s%s", strtoupper(substr($db_type, 0, 1)), strtolower(substr($db_type,1)));
$class_file = sprintf("%sclasses/db/%s.class.php", _XE_PATH_, $class_name);
$class_name = 'DB'.ucfirst($db_type);
$class_file = _XE_PATH_."classes/db/$class_name.class.php";
if(!file_exists($class_file)) new Object(-1, 'msg_db_not_setted');
require_once($class_file);
$get_db = create_function('', sprintf('$GLOBALS["__DB__"]["%s"] = new %s();', $db_type, $class_name));
$get_db();
// get a singletone instance of the database driver class
require_once($class_file);
$GLOBALS['__DB__'][$db_type] = call_user_func(array($class_name, 'create'));
}
return $GLOBALS['__DB__'][$db_type];

View file

@ -51,6 +51,14 @@
$this->_setDBInfo();
$this->_connect();
}
/**
* @brief create an instance of this class
*/
function create()
{
return new DBCubrid;
}
/**
* @brief 설치 가능 여부를 return
@ -1244,4 +1252,6 @@
return $buff;
}
}
return new DBCubrid;
?>

View file

@ -45,6 +45,14 @@
$this->_setDBInfo();
$this->_connect();
}
/**
* @brief create an instance of this class
*/
function create()
{
return new DBFireBird;
}
/**
* @brief 설치 가능 여부를 return
@ -1057,4 +1065,6 @@
return $buff;
}
}
return new DBFireBird;
?>

View file

@ -42,6 +42,14 @@
$this->_setDBInfo();
$this->_connect();
}
/**
* @brief create an instance of this class
*/
function create()
{
return new DBMssql;
}
/**
* @brief 설치 가능 여부를 return
@ -895,4 +903,6 @@
}
}
return new DBMssql;
?>

View file

@ -44,6 +44,10 @@
$this->_setDBInfo();
$this->_connect();
}
function create() {
return new DBMysql;
}
/**
* @brief 설치 가능 여부를 return
@ -771,4 +775,4 @@
return mysql_fetch_object($result);
}
}
?>
?>

View file

@ -19,6 +19,14 @@
$this->_setDBInfo();
$this->_connect();
}
/**
* @brief create an instance of this class
*/
function create()
{
return new DBMysql_innodb;
}
/**
* @brief DB접속 해제
@ -151,4 +159,6 @@
if(!$output) return false;
}
}
return new DBMysql_innodb;
?>

View file

@ -27,6 +27,14 @@
if(!function_exists('mysqli_connect')) return false;
return true;
}
/**
* @brief create an instance of this class
*/
function create()
{
return new DBMysqli;
}
/**
* @brief DB 접속
@ -110,4 +118,6 @@
return mysqli_fetch_object($result);
}
}
return new DBMysqli;
?>

View file

@ -50,6 +50,14 @@ class DBPostgresql extends DB
$this->_setDBInfo();
$this->_connect();
}
/**
* @brief create an instance of this class
*/
function create()
{
return new DBPostgresql;
}
/**
* @brief 설치 가능 여부를 return
@ -927,4 +935,6 @@ class DBPostgresql extends DB
return $buff;
}
}
return new DBPostgresql;
?>

View file

@ -41,6 +41,14 @@
$this->_setDBInfo();
$this->_connect();
}
/**
* @brief create an instance of this class
*/
function create()
{
return new DBSqlite2;
}
/**
* @brief 설치 가능 여부를 return
@ -722,4 +730,6 @@
return $buff;
}
}
return new DBSqlite2;
?>

View file

@ -47,6 +47,14 @@
$this->_setDBInfo();
$this->_connect();
}
/**
* @brief create an instance of this class
*/
function create()
{
return new DBSqlite3_pdo;
}
/**
* @brief 설치 가능 여부를 return
@ -806,4 +814,6 @@
return $buff;
}
}
return new DBSqlite3_pdo;
?>