mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-02 08:42:15 +09:00
english comments added
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0_english@8278 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
693e215bc1
commit
4d272994dd
219 changed files with 6407 additions and 8705 deletions
|
|
@ -3,26 +3,26 @@
|
|||
/**
|
||||
* @class DBMSSQL
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief MSSQL driver로 수정 sol (sol@ngleader.com)
|
||||
* @brief Modified to use MSSQL driver by sol (sol@ngleader.com)
|
||||
* @version 0.1
|
||||
**/
|
||||
|
||||
class DBMssql extends DB {
|
||||
|
||||
/**
|
||||
* DB를 이용하기 위한 정보
|
||||
* information to connect to DB
|
||||
**/
|
||||
var $conn = NULL;
|
||||
var $database = NULL; ///< database
|
||||
var $prefix = 'xe'; ///< XE에서 사용할 테이블들의 prefix (한 DB에서 여러개의 XE 설치 가능)
|
||||
var $prefix = 'xe'; // / <prefix of XE tables(One more XE can be installed on a single DB)
|
||||
var $param = array();
|
||||
var $comment_syntax = '/* %s */';
|
||||
|
||||
/**
|
||||
* @brief mssql 에서 사용될 column type
|
||||
* @brief column type used in mssql
|
||||
*
|
||||
* column_type은 schema/query xml에서 공통 선언된 type을 이용하기 때문에
|
||||
* 각 DBMS에 맞게 replace 해주어야 한다
|
||||
* column_type should be replaced for each DBMS's type
|
||||
* becasue it uses commonly defined type in the schema/query xml
|
||||
**/
|
||||
var $column_type = array(
|
||||
'bignumber' => 'bigint',
|
||||
|
|
@ -52,7 +52,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 설치 가능 여부를 return
|
||||
* @brief Return if installable
|
||||
**/
|
||||
function isSupported() {
|
||||
if (!extension_loaded("sqlsrv")) return false;
|
||||
|
|
@ -60,7 +60,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief DB정보 설정 및 connect/ close
|
||||
* @brief DB settings and connect/close
|
||||
**/
|
||||
function _setDBInfo() {
|
||||
$db_info = Context::getDBInfo();
|
||||
|
|
@ -75,10 +75,10 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief DB 접속
|
||||
* @brief DB Connection
|
||||
**/
|
||||
function _connect() {
|
||||
// db 정보가 없으면 무시
|
||||
// ignore if db information not exists
|
||||
if(!$this->hostname || !$this->database) return;
|
||||
|
||||
//sqlsrv_configure( 'WarningsReturnAsErrors', 0 );
|
||||
|
|
@ -89,7 +89,8 @@
|
|||
array( 'Database' => $this->database,'UID'=>$this->userid,'PWD'=>$this->password ));
|
||||
|
||||
|
||||
// 접속체크
|
||||
// Check connections
|
||||
|
||||
if($this->conn){
|
||||
$this->is_connected = true;
|
||||
$this->password = md5($this->password);
|
||||
|
|
@ -99,7 +100,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief DB접속 해제
|
||||
* @brief DB disconnect
|
||||
**/
|
||||
function close() {
|
||||
if($this->is_connected == false) return;
|
||||
|
|
@ -110,7 +111,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 쿼리에서 입력되는 문자열 변수들의 quotation 조절
|
||||
* @brief handles quatation of the string variables from the query
|
||||
**/
|
||||
function addQuotes($string) {
|
||||
if(version_compare(PHP_VERSION, "5.9.0", "<") && get_magic_quotes_gpc()) $string = stripslashes(str_replace("\\","\\\\",$string));
|
||||
|
|
@ -120,7 +121,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 트랜잭션 시작
|
||||
* @brief Begin transaction
|
||||
**/
|
||||
function begin() {
|
||||
if($this->is_connected == false || $this->transaction_started) return;
|
||||
|
|
@ -130,7 +131,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 롤백
|
||||
* @brief Rollback
|
||||
**/
|
||||
function rollback() {
|
||||
if($this->is_connected == false || !$this->transaction_started) return;
|
||||
|
|
@ -140,7 +141,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 커밋
|
||||
* @brief Commit
|
||||
**/
|
||||
function commit($force = false) {
|
||||
if(!$force && ($this->is_connected == false || !$this->transaction_started)) return;
|
||||
|
|
@ -150,13 +151,13 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief : 쿼리문의 실행 및 결과의 fetch 처리
|
||||
* @brief : executing the query and fetching the result
|
||||
*
|
||||
* query : query문 실행하고 result return\n
|
||||
* fetch : reutrn 된 값이 없으면 NULL\n
|
||||
* rows이면 array object\n
|
||||
* row이면 object\n
|
||||
* return\n
|
||||
* query: run a query and return the result\n
|
||||
* fetch: NULL if no value returned \n
|
||||
* array object if rows returned \n
|
||||
* object if a row returned \n
|
||||
* return\n
|
||||
**/
|
||||
function _query($query) {
|
||||
if($this->is_connected == false || !$query) return;
|
||||
|
|
@ -173,21 +174,21 @@
|
|||
}
|
||||
}
|
||||
|
||||
// 쿼리 시작을 알림
|
||||
// Notify to start a query execution
|
||||
$this->actStart($query);
|
||||
|
||||
// 쿼리 문 실행
|
||||
// Run the query statement
|
||||
$result = false;
|
||||
if(count($_param)){
|
||||
$result = @sqlsrv_query($this->conn, $query, $_param);
|
||||
}else{
|
||||
$result = @sqlsrv_query($this->conn, $query);
|
||||
}
|
||||
|
||||
// 오류 체크
|
||||
// Error Check
|
||||
|
||||
if(!$result) $this->setError(print_r(sqlsrv_errors(),true));
|
||||
|
||||
// 쿼리 실행 종료를 알림
|
||||
// Notify to complete a query execution
|
||||
$this->actFinish();
|
||||
$this->param = array();
|
||||
|
||||
|
|
@ -195,7 +196,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 결과를 fetch
|
||||
* @brief Fetch results
|
||||
**/
|
||||
function _fetch($result) {
|
||||
if(!$this->isConnected() || $this->isError() || !$result) return;
|
||||
|
|
@ -219,7 +220,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 1씩 증가되는 sequence값을 return (mssql의 auto_increment는 sequence테이블에서만 사용)
|
||||
* @brief Return sequence value incremented by 1(auto_increment is usd in the sequence table only)
|
||||
**/
|
||||
function getNextSequence() {
|
||||
$query = sprintf("insert into %ssequence (seq) values (ident_incr('%ssequence'))", $this->prefix, $this->prefix);
|
||||
|
|
@ -234,7 +235,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 테이블 기생성 여부 return
|
||||
* @brief Return if a table already exists
|
||||
**/
|
||||
function isTableExists($target_name) {
|
||||
$query = sprintf("select name from sysobjects where name = '%s%s' and xtype='U'", $this->prefix, $this->addQuotes($target_name));
|
||||
|
|
@ -246,7 +247,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블에 특정 column 추가
|
||||
* @brief Add a column to a table
|
||||
**/
|
||||
function addColumn($table_name, $column_name, $type='number', $size='', $default = '', $notnull=false) {
|
||||
if($this->isColumnExists($table_name, $column_name)) return;
|
||||
|
|
@ -263,7 +264,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블에 특정 column 제거
|
||||
* @brief Delete a column from a table
|
||||
**/
|
||||
function dropColumn($table_name, $column_name) {
|
||||
if(!$this->isColumnExists($table_name, $column_name)) return;
|
||||
|
|
@ -272,7 +273,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블의 column의 정보를 return
|
||||
* @brief Return column information of a table
|
||||
**/
|
||||
function isColumnExists($table_name, $column_name) {
|
||||
$query = sprintf("select syscolumns.name as name from syscolumns, sysobjects where sysobjects.name = '%s%s' and sysobjects.id = syscolumns.id and syscolumns.name = '%s'", $this->prefix, $table_name, $column_name);
|
||||
|
|
@ -284,7 +285,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블에 특정 인덱스 추가
|
||||
* @brief Add an index to a table
|
||||
* $target_columns = array(col1, col2)
|
||||
* $is_unique? unique : none
|
||||
**/
|
||||
|
|
@ -297,7 +298,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블의 특정 인덱스 삭제
|
||||
* @brief Drop an index from a table
|
||||
**/
|
||||
function dropIndex($table_name, $index_name, $is_unique = false) {
|
||||
if(!$this->isIndexExists($table_name, $index_name)) return;
|
||||
|
|
@ -306,7 +307,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블의 index 정보를 return
|
||||
* @brief Return index information of a table
|
||||
**/
|
||||
function isIndexExists($table_name, $index_name) {
|
||||
$query = sprintf("select sysindexes.name as name from sysindexes, sysobjects where sysobjects.name = '%s%s' and sysobjects.id = sysindexes.id and sysindexes.name = '%s'", $this->prefix, $table_name, $index_name);
|
||||
|
|
@ -320,24 +321,24 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief xml 을 받아서 테이블을 생성
|
||||
* @brief Create a table by using xml file
|
||||
**/
|
||||
function createTableByXml($xml_doc) {
|
||||
return $this->_createTable($xml_doc);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief xml 을 받아서 테이블을 생성
|
||||
* @brief Create a table by using xml file
|
||||
**/
|
||||
function createTableByXmlFile($file_name) {
|
||||
if(!file_exists($file_name)) return;
|
||||
// xml 파일을 읽음
|
||||
// read xml file
|
||||
$buff = FileHandler::readFile($file_name);
|
||||
return $this->_createTable($buff);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief schema xml을 이용하여 create table query생성
|
||||
* @brief generate a query statement to create a table by using schema xml
|
||||
*
|
||||
* type : number, varchar, text, char, date, \n
|
||||
* opt : notnull, default, size\n
|
||||
|
|
@ -347,8 +348,7 @@
|
|||
// xml parsing
|
||||
$oXml = new XmlParser();
|
||||
$xml_obj = $oXml->parse($xml_doc);
|
||||
|
||||
// 테이블 생성 schema 작성
|
||||
// Create a table schema
|
||||
$table_name = $xml_obj->table->attrs->name;
|
||||
if($this->isTableExists($table_name)) return;
|
||||
|
||||
|
|
@ -409,7 +409,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 조건문 작성하여 return
|
||||
* @brief Return conditional clause
|
||||
**/
|
||||
function getCondition($output) {
|
||||
if(!$output->conditions) return;
|
||||
|
|
@ -525,16 +525,15 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief insertAct 처리
|
||||
* @brief Handle the insertAct
|
||||
**/
|
||||
function _executeInsertAct($output) {
|
||||
|
||||
// 테이블 정리
|
||||
// List tables
|
||||
foreach($output->tables as $key => $val) {
|
||||
$table_list[] = '['.$this->prefix.$val.']';
|
||||
}
|
||||
|
||||
// 컬럼 정리
|
||||
// List columns
|
||||
foreach($output->columns as $key => $val) {
|
||||
$name = $val['name'];
|
||||
$value = $val['value'];
|
||||
|
|
@ -561,15 +560,16 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief updateAct 처리
|
||||
* @brief Handle updateAct
|
||||
**/
|
||||
function _executeUpdateAct($output) {
|
||||
// 테이블 정리
|
||||
// List tables
|
||||
foreach($output->tables as $key => $val) {
|
||||
$table_list[] = '['.$this->prefix.$val.']';
|
||||
}
|
||||
|
||||
// 컬럼 정리
|
||||
// List columns
|
||||
|
||||
foreach($output->columns as $key => $val) {
|
||||
if(!isset($val['value'])) continue;
|
||||
|
||||
|
|
@ -597,8 +597,7 @@
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
// 조건절 정리
|
||||
// List the conditional clause
|
||||
$condition = $this->getCondition($output);
|
||||
|
||||
$query = sprintf("update %s set %s %s", implode(',',$table_list), implode(',',$column_list), $condition);
|
||||
|
|
@ -607,15 +606,14 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief deleteAct 처리
|
||||
* @brief Handle deleteAct
|
||||
**/
|
||||
function _executeDeleteAct($output) {
|
||||
// 테이블 정리
|
||||
// List tables
|
||||
foreach($output->tables as $key => $val) {
|
||||
$table_list[] = '['.$this->prefix.$val.']';
|
||||
}
|
||||
|
||||
// 조건절 정리
|
||||
// List the conditional clause
|
||||
$condition = $this->getCondition($output);
|
||||
|
||||
$query = sprintf("delete from %s %s", implode(',',$table_list), $condition);
|
||||
|
|
@ -624,13 +622,13 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief selectAct 처리
|
||||
* @brief Handle selectAct
|
||||
*
|
||||
* select의 경우 특정 페이지의 목록을 가져오는 것을 편하게 하기 위해\n
|
||||
* navigation이라는 method를 제공
|
||||
* In order to get a list of pages easily when selecting \n
|
||||
* it supports a method as navigation
|
||||
**/
|
||||
function _executeSelectAct($output) {
|
||||
// 테이블 정리
|
||||
// List tables
|
||||
$table_list = array();
|
||||
foreach($output->tables as $key => $val) {
|
||||
$table_list[] = '['.$this->prefix.$val.'] as '.$key;
|
||||
|
|
@ -675,8 +673,7 @@
|
|||
|
||||
$output->column_list = $column_list;
|
||||
if($output->list_count && $output->page) return $this->_getNavigationData($table_list, $columns, $left_join, $condition, $output);
|
||||
|
||||
// list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가
|
||||
// Add a condition to use an index when sorting in order by list_order, update_order
|
||||
if($output->order) {
|
||||
$conditions = $this->getConditionList($output);
|
||||
if(!in_array('list_order', $conditions) && !in_array('update_order', $conditions)) {
|
||||
|
|
@ -718,7 +715,7 @@
|
|||
}
|
||||
|
||||
$query = sprintf("%s from %s %s %s %s", $columns, implode(',',$table_list),implode(' ',$left_join), $condition, $groupby_query.$orderby_query);
|
||||
// list_count를 사용할 경우 적용
|
||||
// Apply when using list_count
|
||||
if($output->list_count['value']) $query = sprintf('select top %d %s', $output->list_count['value'], $query);
|
||||
else $query = "select ".$query;
|
||||
|
||||
|
|
@ -741,16 +738,16 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief query xml에 navigation 정보가 있을 경우 페이징 관련 작업을 처리한다
|
||||
* @brief Paging is handled if navigation information exists in the query xml
|
||||
*
|
||||
* 그닥 좋지는 않은 구조이지만 편리하다.. -_-;
|
||||
* It is quite convenient although its structure is not good at all .. -_-;
|
||||
**/
|
||||
function _getNavigationData($table_list, $columns, $left_join, $condition, $output) {
|
||||
require_once(_XE_PATH_.'classes/page/PageHandler.class.php');
|
||||
|
||||
$column_list = $output->column_list;
|
||||
|
||||
// 전체 개수를 구함
|
||||
// Get a total count
|
||||
if(count($output->groups)){
|
||||
foreach($output->groups as $k => $v ){
|
||||
if(preg_match('/^substr\(/i',$v)) $output->groups[$k] = preg_replace('/^substr\(/i','substring(',$v);
|
||||
|
|
@ -780,16 +777,13 @@
|
|||
if(!$page_count) $page_count = 10;
|
||||
$page = $output->page['value'];
|
||||
if(!$page) $page = 1;
|
||||
|
||||
// 전체 페이지를 구함
|
||||
// Get a total page
|
||||
if($total_count) $total_page = (int)( ($total_count-1) / $list_count) + 1;
|
||||
else $total_page = 1;
|
||||
|
||||
// 페이지 변수를 체크
|
||||
// Check Page variables
|
||||
if($page > $total_page) $page = $total_page;
|
||||
$start_count = ($page-1)*$list_count;
|
||||
|
||||
// list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가
|
||||
// Add a condition to use an index when sorting in order by list_order, update_order
|
||||
$conditions = $this->getConditionList($output);
|
||||
if($output->order) {
|
||||
if(!in_array('list_order', $conditions) && !in_array('update_order', $conditions)) {
|
||||
|
|
@ -802,7 +796,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
// group by 절 추가
|
||||
// Add group by clause
|
||||
if(count($output->groups)){
|
||||
foreach($output->groups as $k => $v ){
|
||||
if(preg_match('/^substr\(/i',$v)) $output->groups[$k] = preg_replace('/^substr\(/i','substring(',$v);
|
||||
|
|
@ -812,7 +806,7 @@
|
|||
$group = sprintf('group by %s', implode(',',$output->groups));
|
||||
}
|
||||
|
||||
// order 절 추가
|
||||
// Add order by clause
|
||||
$order_targets = array();
|
||||
if($output->order) {
|
||||
foreach($output->order as $key => $val) {
|
||||
|
|
@ -848,7 +842,7 @@
|
|||
$first_sub_columns[] = $k;
|
||||
}
|
||||
|
||||
// 1차로 order 대상에 해당 하는 값을 가져옴
|
||||
// Fetch values to sort
|
||||
$param = $this->param;
|
||||
$first_query = sprintf("select %s from (select top %d %s from %s %s %s %s %s) xet", implode(',',$first_columns), $start_count, implode(',',$first_sub_columns), implode(',',$table_list), implode(' ',$left_join), $condition, $group, $order);
|
||||
$result = $this->_query($first_query);
|
||||
|
|
@ -857,7 +851,7 @@
|
|||
|
||||
|
||||
|
||||
// 1차에서 나온 값을 이용 다시 쿼리 실행
|
||||
// Re-execute a query by using fetched values
|
||||
$sub_cond = array();
|
||||
foreach($order_targets as $k => $v) {
|
||||
$sub_cond[] = sprintf("%s %s '%s'", $k, $v=='asc'?'>':'<', $tmp->{$k});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue