mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-03 09:14:48 +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
|
|
@ -857,7 +857,7 @@ class Context {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 요청이 들어온 URL에서 argument를 제거하여 return
|
||||
* @brief Return after removing an argument on the requested URL
|
||||
**/
|
||||
function getRequestUri($ssl_mode = FOLLOW_REQUEST_SSL, $domain = null) {
|
||||
static $url = array();
|
||||
|
|
@ -919,7 +919,7 @@ class Context {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief key값에 해당하는 값을 return
|
||||
* @brief return key value
|
||||
**/
|
||||
function get($key) {
|
||||
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
|
||||
|
|
@ -927,9 +927,9 @@ class Context {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 받고자 하는 변수만 object에 입력하여 받음
|
||||
*
|
||||
* key1, key2, key3 .. 등의 인자를 주어 여러개의 변수를 object vars로 세팅하여 받을 수 있음
|
||||
* @brief get a specified var in object
|
||||
*
|
||||
* get one more vars in object vars with given arguments(key1, key2, key3,...)
|
||||
**/
|
||||
function gets() {
|
||||
$num_args = func_num_args();
|
||||
|
|
@ -944,7 +944,7 @@ class Context {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 모든 데이터를 return
|
||||
* @brief Return all data
|
||||
**/
|
||||
function getAll() {
|
||||
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
|
||||
|
|
@ -952,7 +952,7 @@ class Context {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief GET/POST/XMLRPC에서 넘어온 변수값을 return
|
||||
* @brief Return values from the GET/POST/XMLRPC
|
||||
**/
|
||||
function getRequestVars() {
|
||||
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
|
||||
|
|
@ -960,8 +960,8 @@ class Context {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief SSL로 인증되어야 할 action이 있을 경우 등록
|
||||
* common/js/xml_handler.js에서 이 action들에 대해서 https로 전송되도록 함
|
||||
* @brief Register if actions is to be encrypted by SSL
|
||||
* Those actions are sent to https in common/js/xml_handler.js
|
||||
**/
|
||||
function addSSLAction($action) {
|
||||
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
|
||||
|
|
@ -992,7 +992,7 @@ class Context {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief js file을 추가
|
||||
* @brief Add the js file
|
||||
**/
|
||||
function addJsFile($file, $optimized = false, $targetie = '',$index=0, $type='head') {
|
||||
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
|
||||
|
|
@ -1009,7 +1009,7 @@ class Context {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief js file을 제거
|
||||
* @brief Remove the js file
|
||||
**/
|
||||
function unloadJsFile($file, $optimized = false, $targetie = '') {
|
||||
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
|
||||
|
|
@ -1034,14 +1034,14 @@ class Context {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief javascript filter 추가
|
||||
* @brief Add javascript filter
|
||||
**/
|
||||
function addJsFilter($path, $filename) {
|
||||
$oXmlFilter = new XmlJSFilter($path, $filename);
|
||||
$oXmlFilter->compile();
|
||||
}
|
||||
/**
|
||||
* @brief array_unique와 동작은 동일하나 file 첨자에 대해서만 동작함
|
||||
* @brief Same as array_unique but works only for file subscript
|
||||
* @deprecated
|
||||
**/
|
||||
function _getUniqueFileList($files) {
|
||||
|
|
@ -1080,7 +1080,7 @@ class Context {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief CSS file 추가
|
||||
* @brief Add CSS file
|
||||
**/
|
||||
function addCSSFile($file, $optimized=false, $media='all', $targetie='',$index=0) {
|
||||
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
|
||||
|
|
@ -1092,7 +1092,7 @@ class Context {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief css file을 제거
|
||||
* @brief Remove css file
|
||||
**/
|
||||
function unloadCSSFile($file, $optimized = false, $media = 'all', $targetie = '') {
|
||||
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
|
||||
|
|
@ -1163,7 +1163,7 @@ class Context {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief HtmlHeader 추가
|
||||
* @brief Add HtmlHeader
|
||||
**/
|
||||
function addHtmlHeader($header) {
|
||||
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
|
||||
|
|
@ -1179,7 +1179,7 @@ class Context {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief Html Body에 css class 추가
|
||||
* @brief Add css class to Html Body
|
||||
**/
|
||||
function addBodyClass($class_name) {
|
||||
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
|
||||
|
|
@ -1187,7 +1187,7 @@ class Context {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief Html Body에 css class return
|
||||
* @brief Return css class to Html Body
|
||||
**/
|
||||
function getBodyClass() {
|
||||
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
|
||||
|
|
@ -1251,7 +1251,7 @@ class Context {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 내용의 위젯이나 기타 기능에 대한 code를 실제 code로 변경
|
||||
* @brief Transforms codes about widget or other features into the actual code, deprecatred
|
||||
**/
|
||||
function transContent($content) {
|
||||
return $content;
|
||||
|
|
|
|||
|
|
@ -241,7 +241,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief query xml 파일을 실행하여 결과를 return
|
||||
* @brief Run the result of the query xml file
|
||||
* @param[in] $query_id query id (module.queryname
|
||||
* @param[in] $args arguments for query
|
||||
* @return result of query
|
||||
|
|
|
|||
|
|
@ -2,34 +2,34 @@
|
|||
/**
|
||||
* @class DBCubrid
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief Cubrid DBMS를 이용하기 위한 class
|
||||
* @brief Cubrid DBMS to use the class
|
||||
* @version 0.1p1
|
||||
*
|
||||
* CUBRID2008 R1.3 에 대응하도록 수정 Prototype (prototype@cubrid.com) / 09.02.23
|
||||
* 7.3 ~ 2008 R1.3 까지 테스트 완료함.
|
||||
* 기본 쿼리만 사용하였기에 특화된 튜닝이 필요
|
||||
* Modified to work with CUBRID2008 R1.3 verion by Prototype (prototype@cubrid.com)/09.02.23
|
||||
* Test completed for CUBRID 7.3 ~ 2008 R1.3 versions.
|
||||
* Only basic query used so query tunning and optimization needed
|
||||
**/
|
||||
|
||||
class DBCubrid extends DB
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief Cubrid DB에 접속하기 위한 정보
|
||||
* @brief CUBRID DB connection information
|
||||
**/
|
||||
var $hostname = '127.0.0.1'; ///< hostname
|
||||
var $userid = NULL; ///< user id
|
||||
var $password = NULL; ///< password
|
||||
var $database = NULL; ///< database
|
||||
var $port = 33000; ///< db server port
|
||||
var $prefix = 'xe'; ///< XE에서 사용할 테이블들의 prefix (한 DB에서 여러개의 XE 설치 가능)
|
||||
var $cutlen = 12000; ///< 큐브리드의 최대 상수 크기(스트링이 이보다 크면 '...'+'...' 방식을 사용해야 한다
|
||||
var $prefix = 'xe'; // / <prefix of XE tables(One more XE can be installed on a single DB)
|
||||
var $cutlen = 12000; // /< max size of constant in CUBRID(if string is larger than this, '...'+'...' should be used)
|
||||
var $comment_syntax = '/* %s */';
|
||||
|
||||
/**
|
||||
* @brief cubrid에서 사용될 column type
|
||||
* @brief column type used in CUBRID
|
||||
*
|
||||
* 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' => 'numeric(20)',
|
||||
|
|
@ -61,7 +61,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 설치 가능 여부를 return
|
||||
* @brief Return if installable
|
||||
**/
|
||||
function isSupported()
|
||||
{
|
||||
|
|
@ -70,7 +70,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief DB정보 설정 및 connect/ close
|
||||
* @brief DB settings and connect/close
|
||||
**/
|
||||
function _setDBInfo()
|
||||
{
|
||||
|
|
@ -86,17 +86,17 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief DB 접속
|
||||
* @brief DB Connection
|
||||
**/
|
||||
function _connect()
|
||||
{
|
||||
// db 정보가 없으면 무시
|
||||
// ignore if db information not exists
|
||||
if (!$this->hostname || !$this->userid || !$this->password || !$this->database || !$this->port) return;
|
||||
|
||||
// 접속시도
|
||||
// attempts to connect
|
||||
$this->fd = @cubrid_connect ($this->hostname, $this->port, $this->database, $this->userid, $this->password);
|
||||
|
||||
// 접속체크
|
||||
// check connections
|
||||
if (!$this->fd) {
|
||||
$this->setError (-1, 'database connect fail');
|
||||
return $this->is_connected = false;
|
||||
|
|
@ -107,7 +107,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief DB접속 해제
|
||||
* @brief DB disconnect
|
||||
**/
|
||||
function close()
|
||||
{
|
||||
|
|
@ -119,7 +119,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 쿼리에서 입력되는 문자열 변수들의 quotation 조절
|
||||
* @brief handles quatation of the string variables from the query
|
||||
**/
|
||||
function addQuotes($string)
|
||||
{
|
||||
|
|
@ -147,7 +147,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 트랜잭션 시작
|
||||
* @brief Begin transaction
|
||||
**/
|
||||
function begin()
|
||||
{
|
||||
|
|
@ -156,7 +156,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 롤백
|
||||
* @brief Rollback
|
||||
**/
|
||||
function rollback()
|
||||
{
|
||||
|
|
@ -166,7 +166,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 커밋
|
||||
* @brief Commit
|
||||
**/
|
||||
function commit()
|
||||
{
|
||||
|
|
@ -178,24 +178,24 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @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 (!$query || !$this->isConnected ()) return;
|
||||
|
||||
// 쿼리 시작을 알림
|
||||
// Notify to start a query execution
|
||||
$this->actStart ($query);
|
||||
|
||||
// 쿼리 문 실행
|
||||
// Execute the query
|
||||
$result = @cubrid_execute ($this->fd, $query);
|
||||
// 오류 체크
|
||||
// error check
|
||||
if (cubrid_error_code ()) {
|
||||
$code = cubrid_error_code ();
|
||||
$msg = cubrid_error_msg ();
|
||||
|
|
@ -203,15 +203,15 @@
|
|||
$this->setError ($code, $msg);
|
||||
}
|
||||
|
||||
// 쿼리 실행 종료를 알림
|
||||
// Notify to complete a query execution
|
||||
$this->actFinish ();
|
||||
|
||||
// 결과 리턴
|
||||
// Return the result
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 결과를 fetch
|
||||
* @brief Fetch the result
|
||||
**/
|
||||
function _fetch($result)
|
||||
{
|
||||
|
|
@ -246,7 +246,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 1씩 증가되는 sequence 값을 return (cubrid의 auto_increment는 sequence테이블에서만 사용)
|
||||
* @brief return the sequence value incremented by 1(auto_increment column only used in the CUBRID sequence table)
|
||||
**/
|
||||
function getNextSequence()
|
||||
{
|
||||
|
|
@ -260,7 +260,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 마이그레이션시 sequence 가 없을 경우 생성
|
||||
* @brief return if the table already exists
|
||||
**/
|
||||
function _makeSequence()
|
||||
{
|
||||
|
|
@ -302,7 +302,7 @@
|
|||
|
||||
|
||||
/**
|
||||
* @brief 테이블 기생성 여부 return
|
||||
* brief return a table if exists
|
||||
**/
|
||||
function isTableExists ($target_name)
|
||||
{
|
||||
|
|
@ -327,7 +327,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블에 특정 column 추가
|
||||
* @brief add a column to the table
|
||||
**/
|
||||
function addColumn($table_name, $column_name, $type = 'number', $size = '', $default = '', $notnull = false)
|
||||
{
|
||||
|
|
@ -362,7 +362,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블에 특정 column 제거
|
||||
* @brief drop a column from the table
|
||||
**/
|
||||
function dropColumn ($table_name, $column_name)
|
||||
{
|
||||
|
|
@ -372,7 +372,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블의 column의 정보를 return
|
||||
* @brief return column information of the table
|
||||
**/
|
||||
function isColumnExists ($table_name, $column_name)
|
||||
{
|
||||
|
|
@ -388,7 +388,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블에 특정 인덱스 추가
|
||||
* @brief add an index to the table
|
||||
* $target_columns = array(col1, col2)
|
||||
* $is_unique? unique : none
|
||||
**/
|
||||
|
|
@ -404,7 +404,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블의 특정 인덱스 삭제
|
||||
* @brief drop an index from the table
|
||||
**/
|
||||
function dropIndex ($table_name, $index_name, $is_unique = false)
|
||||
{
|
||||
|
|
@ -414,7 +414,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블의 index 정보를 return
|
||||
* @brief return index information of the table
|
||||
**/
|
||||
function isIndexExists ($table_name, $index_name)
|
||||
{
|
||||
|
|
@ -430,7 +430,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief xml 을 받아서 테이블을 생성
|
||||
* @brief creates a table by using xml file
|
||||
**/
|
||||
function createTableByXml ($xml_doc)
|
||||
{
|
||||
|
|
@ -438,19 +438,19 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief xml 을 받아서 테이블을 생성
|
||||
* @brief creates 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 class query생성
|
||||
* @brief create table by using the schema xml
|
||||
*
|
||||
* type : number, varchar, tinytext, text, bigtext, char, date, \n
|
||||
* opt : notnull, default, size\n
|
||||
|
|
@ -461,14 +461,13 @@
|
|||
// xml parsing
|
||||
$oXml = new XmlParser();
|
||||
$xml_obj = $oXml->parse($xml_doc);
|
||||
|
||||
// 테이블 생성 schema 작성
|
||||
// Create a table schema
|
||||
$table_name = $xml_obj->table->attrs->name;
|
||||
|
||||
// if the table already exists exit function
|
||||
if ($this->isTableExists($table_name)) return;
|
||||
|
||||
// 만약 테이블 이름이 sequence라면 serial 생성
|
||||
// If the table name is sequence, it creates a serial
|
||||
if ($table_name == 'sequence') {
|
||||
$query = sprintf ('create serial "%s" start with 1 increment by 1'.
|
||||
' minvalue 1 '.
|
||||
|
|
@ -563,7 +562,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 조건문 작성하여 return
|
||||
* @brief return the condition
|
||||
**/
|
||||
function getCondition ($output)
|
||||
{
|
||||
|
|
@ -651,16 +650,16 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief insertAct 처리
|
||||
* @brief handles insertAct
|
||||
**/
|
||||
function _executeInsertAct ($output)
|
||||
{
|
||||
// 테이블 정리
|
||||
// tables
|
||||
foreach ($output->tables as $val) {
|
||||
$table_list[] = '"'.$this->prefix.$val.'"';
|
||||
}
|
||||
|
||||
// 컬럼 정리
|
||||
// columns
|
||||
foreach ($output->columns as $key => $val) {
|
||||
$name = $val['name'];
|
||||
$value = $val['value'];
|
||||
|
|
@ -699,18 +698,18 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief updateAct 처리
|
||||
* @brief handles updateAct
|
||||
**/
|
||||
function _executeUpdateAct ($output)
|
||||
{
|
||||
// 테이블 정리
|
||||
// tables
|
||||
foreach ($output->tables as $key => $val) {
|
||||
$table_list[] = '"'.$this->prefix.$val.'" as "'.$key.'"';
|
||||
}
|
||||
|
||||
$check_click_count = true;
|
||||
|
||||
// 컬럼 정리
|
||||
// columns
|
||||
foreach ($output->columns as $key => $val) {
|
||||
if (!isset ($val['value'])) continue;
|
||||
$name = $val['name'];
|
||||
|
|
@ -721,10 +720,10 @@
|
|||
}
|
||||
|
||||
for ($i = 0; $i < $key; $i++) {
|
||||
/* 한문장에 같은 속성에 대한 중복 설정은 큐브리드에서는 허용치 않음 */
|
||||
// not allows to define the same property repeatedly in a single query in CUBRID
|
||||
if ($output->columns[$i]['name'] == $name) break;
|
||||
}
|
||||
if ($i < $key) continue; // 중복이 발견되면 이후의 설정은 무시
|
||||
if ($i < $key) continue; // ignore the rest of properties if duplicated property found
|
||||
|
||||
if (strpos ($name, '.') !== false && strpos ($value, '.') !== false) {
|
||||
$column_list[] = $name.' = '.$value;
|
||||
|
|
@ -742,7 +741,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
// 조건절 정리
|
||||
// conditional clause
|
||||
$condition = $this->getCondition ($output);
|
||||
|
||||
$check_click_count_condition = false;
|
||||
|
|
@ -792,16 +791,16 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief deleteAct 처리
|
||||
* @brief handles deleteAct
|
||||
**/
|
||||
function _executeDeleteAct ($output)
|
||||
{
|
||||
// 테이블 정리
|
||||
// tables
|
||||
foreach ($output->tables as $val) {
|
||||
$table_list[] = '"'.$this->prefix.$val.'"';
|
||||
}
|
||||
|
||||
// 조건절 정리
|
||||
// Conditional clauses
|
||||
$condition = $this->getCondition ($output);
|
||||
|
||||
$query = sprintf ("delete from %s %s", implode (',',$table_list), $condition);
|
||||
|
|
@ -812,14 +811,14 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief selectAct 처리
|
||||
* @brief Handle selectAct
|
||||
*
|
||||
* select의 경우 특정 페이지의 목록을 가져오는 것을 편하게 하기 위해\n
|
||||
* navigation이라는 method를 제공
|
||||
* to get a specific page list easily in select statement,\n
|
||||
* a method, navigation, is used
|
||||
**/
|
||||
function _executeSelectAct ($output)
|
||||
{
|
||||
// 테이블 정리
|
||||
// tables
|
||||
$table_list = array ();
|
||||
foreach ($output->tables as $key => $val) {
|
||||
$table_list[] = '"'.$this->prefix.$val.'" as "'.$key.'"';
|
||||
|
|
@ -966,7 +965,7 @@
|
|||
}
|
||||
|
||||
|
||||
// list_count를 사용할 경우 적용
|
||||
// apply when using list_count
|
||||
if ($output->list_count['value']) {
|
||||
$start_count = 0;
|
||||
$list_count = $output->list_count['value'];
|
||||
|
|
@ -1050,7 +1049,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 현재 시점의 Stack trace를 보여줌.결과를 fetch
|
||||
* @brief displays the current stack trace. Fetch the result
|
||||
**/
|
||||
function backtrace ()
|
||||
{
|
||||
|
|
@ -1102,9 +1101,9 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief query xml에 navigation 정보가 있을 경우 페이징 관련 작업을 처리한다
|
||||
* @brief paginates when navigation info exists in the query xml
|
||||
*
|
||||
* 그닥 좋지는 않은 구조이지만 편리하다.. -_-;
|
||||
* it is convenient although its structure is not good .. -_-;
|
||||
**/
|
||||
function _getNavigationData ($table_list, $columns, $left_join, $condition, $output) {
|
||||
require_once (_XE_PATH_.'classes/page/PageHandler.class.php');
|
||||
|
|
@ -1129,7 +1128,7 @@
|
|||
$page = $output->page['value'];
|
||||
if (!$page) $page = 1;
|
||||
|
||||
// 전체 페이지를 구함
|
||||
// total pages
|
||||
if ($total_count) {
|
||||
$total_page = (int) (($total_count - 1) / $list_count) + 1;
|
||||
}
|
||||
|
|
@ -1137,7 +1136,7 @@
|
|||
$total_page = 1;
|
||||
}
|
||||
|
||||
// 페이지 변수를 체크
|
||||
// check the page variables
|
||||
if ($page > $total_page) $page = $total_page;
|
||||
$start_count = ($page - 1) * $list_count;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
/**
|
||||
* @class DBFriebird
|
||||
* @author 김현식 (dev.hyuns@gmail.com)
|
||||
* @brief Firebird DBMS를 이용하기 위한 class
|
||||
* @class DBFirebird
|
||||
* @author Kim Hyun Sik (dev.hyuns @ gmail.com)
|
||||
* @brief class to use Firebird DBMS
|
||||
* @version 0.3
|
||||
*
|
||||
* firebird handling class
|
||||
|
|
@ -11,21 +11,21 @@
|
|||
class DBFireBird extends DB {
|
||||
|
||||
/**
|
||||
* @brief Firebird DB에 접속하기 위한 정보
|
||||
* @brief connection to Firebird DB
|
||||
**/
|
||||
var $hostname = '127.0.0.1'; ///< hostname
|
||||
var $userid = NULL; ///< user id
|
||||
var $password = NULL; ///< password
|
||||
var $database = NULL; ///< database
|
||||
var $prefix = 'xe'; ///< XE에서 사용할 테이블들의 prefix (한 DB에서 여러개의 XE 설치 가능)
|
||||
var $idx_no = 0; // 인덱스 생성시 사용할 카운터
|
||||
var $prefix = 'xe'; // / <prefix of XE tables(One more XE can be installed on a single DB)
|
||||
var $idx_no = 0; // counter for creating an index
|
||||
var $comment_syntax = '/* %s */';
|
||||
|
||||
/**
|
||||
* @brief firebird에서 사용될 column type
|
||||
* @brief column type used in firebird
|
||||
*
|
||||
* 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',
|
||||
|
|
@ -55,7 +55,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 설치 가능 여부를 return
|
||||
* @brief Return if installable
|
||||
**/
|
||||
function isSupported() {
|
||||
if(!function_exists('ibase_connect')) return false;
|
||||
|
|
@ -63,7 +63,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief DB정보 설정 및 connect/ close
|
||||
* @brief DB settings and connect/close
|
||||
**/
|
||||
function _setDBInfo() {
|
||||
$db_info = Context::getDBInfo();
|
||||
|
|
@ -77,16 +77,14 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief DB 접속
|
||||
* @brief DB Connection
|
||||
**/
|
||||
function _connect() {
|
||||
// db 정보가 없으면 무시
|
||||
// ignore if db information not exists
|
||||
if(!$this->hostname || !$this->port || !$this->userid || !$this->password || !$this->database) return;
|
||||
|
||||
//if(strpos($this->hostname, ':')===false && $this->port) $this->hostname .= ':'.$this->port;
|
||||
|
||||
// 접속시도
|
||||
|
||||
// attempts to connect
|
||||
$host = $this->hostname."/".$this->port.":".$this->database;
|
||||
|
||||
$this->fd = @ibase_connect($host, $this->userid, $this->password);
|
||||
|
|
@ -94,8 +92,7 @@
|
|||
$this->setError(ibase_errcode(), ibase_errmsg());
|
||||
return $this->is_connected = false;
|
||||
}
|
||||
|
||||
// Firebird 버전 확인후 2.0 이하면 오류 표시
|
||||
// Error when Firebird version is lower than 2.0
|
||||
if (($service = ibase_service_attach($this->hostname, $this->userid, $this->password)) != FALSE) {
|
||||
// get server version and implementation strings
|
||||
$server_info = ibase_server_info($service, IBASE_SVC_SERVER_VERSION);
|
||||
|
|
@ -118,14 +115,13 @@
|
|||
@ibase_close($this->fd);
|
||||
return $this->is_connected = false;
|
||||
}
|
||||
|
||||
// 접속체크
|
||||
// Check connections
|
||||
$this->is_connected = true;
|
||||
$this->password = md5($this->password);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DB접속 해제
|
||||
* @brief DB disconnect
|
||||
**/
|
||||
function close() {
|
||||
if(!$this->isConnected()) return;
|
||||
|
|
@ -135,7 +131,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 쿼리에서 입력되는 문자열 변수들의 quotation 조절
|
||||
* @brief handles quatation of the string variables from the query
|
||||
**/
|
||||
function addQuotes($string) {
|
||||
// if(get_magic_quotes_gpc()) $string = stripslashes(str_replace("\\","\\\\",$string));
|
||||
|
|
@ -144,7 +140,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 쿼리에서 입력되는 table, column 명에 더블쿼터를 넣어줌
|
||||
* @brief put double quotes for tabls, column names in the query statement
|
||||
**/
|
||||
function addDoubleQuotes($string) {
|
||||
if($string == "*") return $string;
|
||||
|
|
@ -162,12 +158,11 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 쿼리에서 입력되는 table, column 명에 더블쿼터를 넣어줌
|
||||
* @brief put double quotes for tabls, column names in the query statement
|
||||
**/
|
||||
function autoQuotes($string){
|
||||
$string = strtolower($string);
|
||||
|
||||
// substr 함수 일경우
|
||||
// for substr function
|
||||
if(strpos($string, "substr(") !== false) {
|
||||
$tokken = strtok($string, "(,)");
|
||||
$tokken = strtok("(,)");
|
||||
|
|
@ -190,8 +185,7 @@
|
|||
$as = trim($as);
|
||||
$as = $this->addDoubleQuotes($as);
|
||||
}
|
||||
|
||||
// 함수 사용시
|
||||
// for functions
|
||||
$tmpFunc1 = null;
|
||||
$tmpFunc2 = null;
|
||||
if(($no1 = strpos($string,'('))!==false && ($no2 = strpos($string, ')'))!==false) {
|
||||
|
|
@ -199,8 +193,7 @@
|
|||
$tmpFunc2 = substr($string, $no2, strlen($string)-$no2+1);
|
||||
$string = trim(substr($string, $no1+1, $no2-$no1-1));
|
||||
}
|
||||
|
||||
// (테이블.컬럼) 구조 일때 처리
|
||||
// for (table.column) structure
|
||||
preg_match("/((?i)[a-z0-9_-]+)[.]((?i)[a-z0-9_\-\*]+)/", $string, $matches);
|
||||
|
||||
if($matches) {
|
||||
|
|
@ -225,7 +218,7 @@
|
|||
}
|
||||
|
||||
foreach($values as $val1) {
|
||||
// (테이블.컬럼) 구조 일때 처리
|
||||
// for (table.column) structure
|
||||
preg_match("/((?i)[a-z0-9_-]+)[.]((?i)[a-z0-9_\-\*]+)/", $val1, $matches);
|
||||
if($matches) {
|
||||
$isTable = false;
|
||||
|
|
@ -257,7 +250,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 트랜잭션 시작
|
||||
* @brief Begin transaction
|
||||
**/
|
||||
function begin() {
|
||||
if(!$this->isConnected() || $this->transaction_started) return;
|
||||
|
|
@ -265,7 +258,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 롤백
|
||||
* @brief Rollback
|
||||
**/
|
||||
function rollback() {
|
||||
if(!$this->isConnected() || !$this->transaction_started) return;
|
||||
|
|
@ -274,7 +267,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 커밋
|
||||
* @brief Commits
|
||||
**/
|
||||
function commit() {
|
||||
if(!$force && (!$this->isConnected() || !$this->transaction_started)) return;
|
||||
|
|
@ -283,48 +276,43 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief : 쿼리문의 실행 및 결과의 fetch 처리
|
||||
* @brief : Run a query and fetch 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, $params=null) {
|
||||
if(!$this->isConnected()) return;
|
||||
|
||||
if(count($params) == 0) {
|
||||
// 쿼리 시작을 알림
|
||||
// Notify to start a query execution
|
||||
$this->actStart($query);
|
||||
|
||||
// 쿼리 문 실행
|
||||
// Execute the query statement
|
||||
$result = ibase_query($this->fd, $query);
|
||||
}
|
||||
else {
|
||||
// 쿼리 시작을 알림
|
||||
// Notify to start a query execution
|
||||
$log = $query."\n\t\t\t";
|
||||
$log .= implode(",", $params);
|
||||
$this->actStart($log);
|
||||
|
||||
// 쿼리 문 실행 (blob type 입력하기 위한 방법)
|
||||
// Execute the query(for blob type)
|
||||
$query = ibase_prepare($this->fd, $query);
|
||||
$fnarr = array_merge(array($query), $params);
|
||||
$result = call_user_func_array("ibase_execute", $fnarr);
|
||||
}
|
||||
|
||||
// 오류 체크
|
||||
// Error Check
|
||||
if(ibase_errmsg()) $this->setError(ibase_errcode(), ibase_errmsg());
|
||||
|
||||
// 쿼리 실행 종료를 알림
|
||||
// Notify to complete a query execution
|
||||
$this->actFinish();
|
||||
|
||||
// 결과 리턴
|
||||
// Return the result
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 결과를 fetch
|
||||
* @brief Fetch the result
|
||||
**/
|
||||
function _fetch($result, $output = null) {
|
||||
if(!$this->isConnected() || $this->isError() || !$result) return;
|
||||
|
|
@ -332,12 +320,11 @@
|
|||
while($tmp = ibase_fetch_object($result)) {
|
||||
foreach($tmp as $key => $val) {
|
||||
$type = $output->column_type[$key];
|
||||
|
||||
// type 값이 null 일때는 $key값이 alias인 경우라 실제 column 이름을 찾아 type을 구함
|
||||
// type value is null when $key is an alias. so get a type by finding actual coloumn name
|
||||
if($type == null && $output->columns && count($output->columns)) {
|
||||
foreach($output->columns as $cols) {
|
||||
if($cols['alias'] == $key) {
|
||||
// table.column 형식인지 정규식으로 검사 함
|
||||
// checks if the format is table.column or a regular expression
|
||||
preg_match("/\w+[.](\w+)/", $cols['name'], $matches);
|
||||
if($matches) {
|
||||
$type = $output->column_type[$matches[1]];
|
||||
|
|
@ -356,7 +343,7 @@
|
|||
ibase_blob_close($blob_hndl);
|
||||
}
|
||||
else if($type == "char") {
|
||||
$tmp->{$key} = trim($tmp->{$key}); // DB의 character set이 UTF8일때 생기는 빈칸을 제거
|
||||
$tmp->{$key} = trim($tmp->{$key}); // remove blanks generated when DB character set is UTF8
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -368,7 +355,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 1씩 증가되는 sequence값을 return (firebird의 generator 값을 증가)
|
||||
* @brief return sequence value incremented by 1(increase the value of the generator in firebird)
|
||||
**/
|
||||
function getNextSequence() {
|
||||
$gen = "GEN_".$this->prefix."sequence_ID";
|
||||
|
|
@ -377,7 +364,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 테이블 기생성 여부 return
|
||||
* @brief returns if the table already exists
|
||||
**/
|
||||
function isTableExists($target_name) {
|
||||
$query = sprintf("select rdb\$relation_name from rdb\$relations where rdb\$system_flag=0 and rdb\$relation_name = '%s%s';", $this->prefix, $target_name);
|
||||
|
|
@ -392,7 +379,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블에 특정 column 추가
|
||||
* @brief add a column to the table
|
||||
**/
|
||||
function addColumn($table_name, $column_name, $type='number', $size='', $default = '', $notnull=false) {
|
||||
$type = $this->column_type[$type];
|
||||
|
|
@ -412,7 +399,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블에 특정 column 제거
|
||||
* @brief drop a column from the table
|
||||
**/
|
||||
function dropColumn($table_name, $column_name) {
|
||||
$query = sprintf("alter table %s%s drop %s ", $this->prefix, $table_name, $column_name);
|
||||
|
|
@ -422,7 +409,7 @@
|
|||
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블의 column의 정보를 return
|
||||
* @brief return column information of the table
|
||||
**/
|
||||
function isColumnExists($table_name, $column_name) {
|
||||
$query = sprintf("SELECT RDB\$FIELD_NAME as \"FIELD\" FROM RDB\$RELATION_FIELDS WHERE RDB\$RELATION_NAME = '%s%s'", $this->prefix, $table_name);
|
||||
|
|
@ -446,15 +433,14 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블에 특정 인덱스 추가
|
||||
* @brief add an index to the table
|
||||
* $target_columns = array(col1, col2)
|
||||
* $is_unique? unique : none
|
||||
**/
|
||||
function addIndex($table_name, $index_name, $target_columns, $is_unique = false) {
|
||||
// index name 크기가 31byte로 제한으로 index name을 넣지 않음
|
||||
// Firebird에서는 index name을 넣지 않으면 "RDB$10"처럼 자동으로 이름을 부여함
|
||||
// table을 삭제 할 경우 인덱스도 자동으로 삭제 됨
|
||||
|
||||
// index name size should be limited to 31 byte. no index name assigned
|
||||
// if index name omitted, Firebird automatically assign its name like "RDB $10"
|
||||
// deletes indexes when deleting the table
|
||||
if(!is_array($target_columns)) $target_columns = array($target_columns);
|
||||
|
||||
$query = sprintf('CREATE %s INDEX "" ON "%s%s" ("%s");', $is_unique?'UNIQUE':'', $this->prefix, $table_name, implode('", "',$target_columns));
|
||||
|
|
@ -464,7 +450,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블의 특정 인덱스 삭제
|
||||
* @brief drop an index from the table
|
||||
**/
|
||||
function dropIndex($table_name, $index_name, $is_unique = false) {
|
||||
$query = sprintf('DROP INDEX "%s" ON "%s%s"', $index_name, $this->prefix, $table_name);
|
||||
|
|
@ -475,7 +461,7 @@
|
|||
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블의 index 정보를 return
|
||||
* @brief return index information of the table
|
||||
**/
|
||||
function isIndexExists($table_name, $index_name) {
|
||||
$query = "SELECT\n";
|
||||
|
|
@ -512,24 +498,24 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief xml 을 받아서 테이블을 생성
|
||||
* @brief creates a table by using xml file
|
||||
**/
|
||||
function createTableByXml($xml_doc) {
|
||||
return $this->_createTable($xml_doc);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief xml 을 받아서 테이블을 생성
|
||||
* @brief creates 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 create table by using the schema xml
|
||||
*
|
||||
* type : number, varchar, text, char, date, \n
|
||||
* opt : notnull, default, size\n
|
||||
|
|
@ -539,8 +525,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;
|
||||
$table_name = $this->prefix.$table_name;
|
||||
|
|
@ -596,10 +581,9 @@
|
|||
|
||||
if(count($index_list)) {
|
||||
foreach($index_list as $key => $val) {
|
||||
// index name 크기가 31byte로 제한으로 index name을 넣지 않음
|
||||
// Firebird에서는 index name을 넣지 않으면 "RDB$10"처럼 자동으로 이름을 부여함
|
||||
// table을 삭제 할 경우 인덱스도 자동으로 삭제 됨
|
||||
|
||||
// index name size should be limited to 31 byte. no index name assigned
|
||||
// if index name omitted, Firebird automatically assign its name like "RDB $10"
|
||||
// deletes indexes when deleting the table
|
||||
$schema = sprintf("CREATE INDEX \"\" ON \"%s\" (\"%s\");",
|
||||
$table_name, implode($val, "\",\""));
|
||||
$output = $this->_query($schema);
|
||||
|
|
@ -613,12 +597,11 @@
|
|||
$output = $this->_query($schema);
|
||||
if(!$this->transaction_started) @ibase_commit($this->fd);
|
||||
if(!$output) return false;
|
||||
|
||||
// Firebird에서 auto increment는 generator를 만들어 insert 발생시 트리거를 실행시켜
|
||||
// generator의 값을 증가시키고 그값을 테이블에 넣어주는 방식을 사용함.
|
||||
// 아래 트리거가 auto increment 역할을 하지만 쿼리로 트리거 등록이 되지 않아 주석처리 하였음.
|
||||
// php 함수에서 generator 값을 증가시켜 주는 함수가 있어 XE에서는 굳이
|
||||
// auto increment를 사용 할 필요가 없어보임.
|
||||
// auto_increment in Firebird creates a generator which activates a trigger when insert occurs
|
||||
// the generator increases the value of the generator and then insert to the table
|
||||
// The trigger below acts like auto_increment however I commented the below because the trigger cannot be defined by a query statement
|
||||
// php api has a function to increase a generator, so
|
||||
// no need to use auto increment in XE
|
||||
/*
|
||||
$schema = 'SET TERM ^ ; ';
|
||||
$schema .= sprintf('CREATE TRIGGER "%s_BI" FOR "%s" ', $table_name, $table_name);
|
||||
|
|
@ -634,7 +617,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 조건문 작성하여 return
|
||||
* @brief Return conditional clause
|
||||
**/
|
||||
function getCondition($output) {
|
||||
if(!$output->conditions) return;
|
||||
|
|
@ -683,15 +666,14 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief insertAct 처리
|
||||
* @brief Handle the insertAct
|
||||
**/
|
||||
function _executeInsertAct($output) {
|
||||
// 테이블 정리
|
||||
// tables
|
||||
foreach($output->tables as $key => $val) {
|
||||
$table_list[] = '"'.$this->prefix.$val.'"';
|
||||
}
|
||||
|
||||
// 컬럼 정리
|
||||
// Columns
|
||||
foreach($output->columns as $key => $val) {
|
||||
$name = $val['name'];
|
||||
$value = $val['value'];
|
||||
|
|
@ -721,15 +703,14 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief updateAct 처리
|
||||
* @brief handles updateAct
|
||||
**/
|
||||
function _executeUpdateAct($output) {
|
||||
// 테이블 정리
|
||||
// Tables
|
||||
foreach($output->tables as $key => $val) {
|
||||
$table_list[] = '"'.$this->prefix.$val.'"';
|
||||
}
|
||||
|
||||
// 컬럼 정리
|
||||
// Columns
|
||||
foreach($output->columns as $key => $val) {
|
||||
if(!isset($val['value'])) continue;
|
||||
$name = $val['name'];
|
||||
|
|
@ -747,7 +728,7 @@
|
|||
else if($output->column_type[$name]=='number' ||
|
||||
$output->column_type[$name]=='bignumber' ||
|
||||
$output->column_type[$name]=='float') {
|
||||
// 연산식이 들어갔을 경우 컬럼명이 있는 지 체크해 더블쿼터를 넣어줌
|
||||
// put double-quotes on column name if an expression is entered
|
||||
preg_match("/(?i)[a-z][a-z0-9_]+/", $value, $matches);
|
||||
|
||||
foreach($matches as $key => $val) {
|
||||
|
|
@ -764,8 +745,7 @@
|
|||
$column_list[] = sprintf('"%s" = ?', $name);
|
||||
}
|
||||
}
|
||||
|
||||
// 조건절 정리
|
||||
// conditional clause
|
||||
$condition = $this->getCondition($output);
|
||||
|
||||
$query = sprintf("update %s set %s %s;", implode(',',$table_list), implode(',',$column_list), $condition);
|
||||
|
|
@ -775,15 +755,14 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief deleteAct 처리
|
||||
* @brief handles deleteAct
|
||||
**/
|
||||
function _executeDeleteAct($output) {
|
||||
// 테이블 정리
|
||||
// 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);
|
||||
|
|
@ -794,13 +773,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) {
|
||||
// 테이블 정리
|
||||
// Tables
|
||||
$table_list = array();
|
||||
foreach($output->tables as $key => $val) {
|
||||
$table_list[] = sprintf("\"%s%s\" as \"%s\"", $this->prefix, $val, $key);
|
||||
|
|
@ -839,8 +818,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에 쿼리 추가
|
||||
// query added in the condition to use an index when ordering by list_order, update_order
|
||||
if($output->order) {
|
||||
$conditions = $this->getConditionList($output);
|
||||
if(!in_array('list_order', $conditions) && !in_array('update_order', $conditions)) {
|
||||
|
|
@ -852,8 +830,7 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// list_count를 사용할 경우 적용
|
||||
// apply when using list_count
|
||||
if($output->list_count['value']) $limit = sprintf('FIRST %d', $output->list_count['value']);
|
||||
else $limit = '';
|
||||
|
||||
|
|
@ -910,9 +887,9 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief query xml에 navigation 정보가 있을 경우 페이징 관련 작업을 처리한다
|
||||
* @brief paginates when navigation info exists in the query xml
|
||||
*
|
||||
* 그닥 좋지는 않은 구조이지만 편리하다.. -_-;
|
||||
* it is convenient although its structure is not good .. -_-;
|
||||
**/
|
||||
function _getNavigationData($table_list, $columns, $left_join, $condition, $output) {
|
||||
require_once(_XE_PATH_.'classes/page/PageHandler.class.php');
|
||||
|
|
@ -929,8 +906,8 @@
|
|||
}
|
||||
|
||||
/*
|
||||
// group by 절이 포함된 SELECT 쿼리의 전체 갯수를 구하기 위한 수정
|
||||
// 정상적인 동작이 확인되면 주석으로 막아둔 부분으로 대체합니다.
|
||||
// modified to get the number of rows by SELECT query with group by clause
|
||||
// activate the commented codes when you confirm it works correctly
|
||||
//
|
||||
$count_condition = strlen($query_groupby) ? sprintf('%s group by %s', $condition, $query_groupby) : $condition;
|
||||
$total_count = $this->getCountCache($output->tables, $count_condition);
|
||||
|
|
@ -944,8 +921,7 @@
|
|||
$this->putCountCache($output->tables, $count_condition, $total_count);
|
||||
}
|
||||
*/
|
||||
|
||||
// 전체 개수를 구함
|
||||
// total number of rows
|
||||
$count_query = sprintf("select count(*) as \"count\" from %s %s %s", implode(',',$table_list),implode(' ',$left_join), $condition);
|
||||
$count_query .= (__DEBUG_QUERY__&1 && $output->query_id)?sprintf(' '.$this->comment_syntax,$this->query_id . ' count(*)'):'';
|
||||
$result = $this->_query($count_query);
|
||||
|
|
@ -960,16 +936,13 @@
|
|||
if(!$page_count) $page_count = 10;
|
||||
$page = $output->page['value'];
|
||||
if(!$page) $page = 1;
|
||||
|
||||
// 전체 페이지를 구함
|
||||
// total pages
|
||||
if($total_count) $total_page = (int)( ($total_count-1) / $list_count) + 1;
|
||||
else $total_page = 1;
|
||||
|
||||
// 페이지 변수를 체크
|
||||
// check the page variables
|
||||
if($page > $total_page) $page = $total_page;
|
||||
$start_count = ($page-1)*$list_count;
|
||||
|
||||
// list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가
|
||||
// query added in the condition to use an index when ordering by list_order, update_order
|
||||
if($output->order) {
|
||||
$conditions = $this->getConditionList($output);
|
||||
if(!in_array('list_order', $conditions) && !in_array('update_order', $conditions)) {
|
||||
|
|
@ -1025,12 +998,11 @@
|
|||
while($tmp = ibase_fetch_object($result)) {
|
||||
foreach($tmp as $key => $val){
|
||||
$type = $output->column_type[$key];
|
||||
|
||||
// type 값이 null 일때는 $key값이 alias인 경우라 실제 column 이름을 찾아 type을 구함
|
||||
// $key value is an alias when type value is null. get type by finding the actual column name
|
||||
if($type == null && $output->columns && count($output->columns)) {
|
||||
foreach($output->columns as $cols) {
|
||||
if($cols['alias'] == $key) {
|
||||
// table.column 형식인지 정규식으로 검사 함
|
||||
// checks if the format is table.column or a regular expression
|
||||
preg_match("/\w+[.](\w+)/", $cols['name'], $matches);
|
||||
if($matches) {
|
||||
$type = $output->column_type[$matches[1]];
|
||||
|
|
|
|||
|
|
@ -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});
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* @class DBMysql
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief MySQL DBMS를 이용하기 위한 class
|
||||
* @brief Class to use MySQL DBMS
|
||||
* @version 0.1
|
||||
*
|
||||
* mysql handling class
|
||||
|
|
@ -11,20 +11,20 @@
|
|||
class DBMysql extends DB {
|
||||
|
||||
/**
|
||||
* @brief Mysql DB에 접속하기 위한 정보
|
||||
* @brief Connection information for Mysql DB
|
||||
**/
|
||||
var $hostname = '127.0.0.1'; ///< hostname
|
||||
var $userid = NULL; ///< user id
|
||||
var $password = NULL; ///< password
|
||||
var $database = NULL; ///< database
|
||||
var $prefix = 'xe'; ///< XE에서 사용할 테이블들의 prefix (한 DB에서 여러개의 XE 설치 가능)
|
||||
var $prefix = 'xe'; // / <prefix of a tablename (One or more XEs can be installed in a single DB)
|
||||
var $comment_syntax = '/* %s */';
|
||||
|
||||
/**
|
||||
* @brief mysql에서 사용될 column type
|
||||
* @brief Column type used in MySQL
|
||||
*
|
||||
* column_type은 schema/query xml에서 공통 선언된 type을 이용하기 때문에
|
||||
* 각 DBMS에 맞게 replace 해주어야 한다
|
||||
* Becasue a common column type in schema/query xml is used for colum_type,
|
||||
* it should be replaced properly for each DBMS
|
||||
**/
|
||||
var $column_type = array(
|
||||
'bignumber' => 'bigint',
|
||||
|
|
@ -50,7 +50,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 설치 가능 여부를 return
|
||||
* @brief Return if it is installable
|
||||
**/
|
||||
function isSupported() {
|
||||
if(!function_exists('mysql_connect')) return false;
|
||||
|
|
@ -58,7 +58,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief DB정보 설정 및 connect/ close
|
||||
* @brief DB settings and connect/close
|
||||
**/
|
||||
function _setDBInfo() {
|
||||
$db_info = Context::getDBInfo();
|
||||
|
|
@ -72,44 +72,39 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief DB 접속
|
||||
* @brief DB Connection
|
||||
**/
|
||||
function _connect() {
|
||||
// db 정보가 없으면 무시
|
||||
// Ignore if no DB information exists
|
||||
if(!$this->hostname || !$this->userid || !$this->password || !$this->database) return;
|
||||
|
||||
if(strpos($this->hostname, ':')===false && $this->port) $this->hostname .= ':'.$this->port;
|
||||
|
||||
// 접속시도
|
||||
// Attempt to connect
|
||||
$this->fd = @mysql_connect($this->hostname, $this->userid, $this->password);
|
||||
if(mysql_error()) {
|
||||
$this->setError(mysql_errno(), mysql_error());
|
||||
return;
|
||||
}
|
||||
|
||||
// 버전 확인후 4.1 이하면 오류 표시
|
||||
// Error appears if the version is lower than 4.1
|
||||
if(mysql_get_server_info($this->fd)<"4.1") {
|
||||
$this->setError(-1, "XE cannot be installed under the version of mysql 4.1. Current mysql version is ".mysql_get_server_info());
|
||||
return;
|
||||
}
|
||||
|
||||
// db 선택
|
||||
// select db
|
||||
@mysql_select_db($this->database, $this->fd);
|
||||
if(mysql_error()) {
|
||||
$this->setError(mysql_errno(), mysql_error());
|
||||
return;
|
||||
}
|
||||
|
||||
// 접속체크
|
||||
// Check connections
|
||||
$this->is_connected = true;
|
||||
$this->password = md5($this->password);
|
||||
|
||||
// mysql의 경우 utf8임을 지정
|
||||
// Set utf8 if a database is MySQL
|
||||
$this->_query("set names 'utf8'");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DB접속 해제
|
||||
* @brief DB disconnection
|
||||
**/
|
||||
function close() {
|
||||
if(!$this->isConnected()) return;
|
||||
|
|
@ -117,7 +112,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 쿼리에서 입력되는 문자열 변수들의 quotation 조절
|
||||
* @brief Add quotes on the string variables in a query
|
||||
**/
|
||||
function addQuotes($string) {
|
||||
if(version_compare(PHP_VERSION, "5.9.0", "<") && get_magic_quotes_gpc()) $string = stripslashes(str_replace("\\","\\\\",$string));
|
||||
|
|
@ -126,53 +121,48 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 트랜잭션 시작
|
||||
* @brief Begin transaction
|
||||
**/
|
||||
function begin() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 롤백
|
||||
* @brief Rollback
|
||||
**/
|
||||
function rollback() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 커밋
|
||||
* @brief Commits
|
||||
**/
|
||||
function commit() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief : 쿼리문의 실행 및 결과의 fetch 처리
|
||||
* @brief : Run a query and fetch the result
|
||||
*
|
||||
* query : query문 실행하고 result return\n
|
||||
* fetch : reutrn 된 값이 없으면 NULL\n
|
||||
* rows이면 array object\n
|
||||
* row이면 object\n
|
||||
* query: run a query and return the result \n
|
||||
* fetch: NULL if no value is returned \n
|
||||
* array object if rows are returned \n
|
||||
* object if a row is returned \n
|
||||
* return\n
|
||||
**/
|
||||
function _query($query) {
|
||||
if(!$this->isConnected()) return;
|
||||
|
||||
// 쿼리 시작을 알림
|
||||
// Notify to start a query execution
|
||||
$this->actStart($query);
|
||||
|
||||
// 쿼리 문 실행
|
||||
// Run the query statement
|
||||
$result = @mysql_query($query, $this->fd);
|
||||
|
||||
// 오류 체크
|
||||
// Error Check
|
||||
if(mysql_error($this->fd)) $this->setError(mysql_errno($this->fd), mysql_error($this->fd));
|
||||
|
||||
// 쿼리 실행 종료를 알림
|
||||
// Notify to complete a query execution
|
||||
$this->actFinish();
|
||||
|
||||
// 결과 리턴
|
||||
// Return result
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 결과를 fetch
|
||||
* @brief Fetch results
|
||||
**/
|
||||
function _fetch($result) {
|
||||
if(!$this->isConnected() || $this->isError() || !$result) return;
|
||||
|
|
@ -184,7 +174,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 1씩 증가되는 sequence값을 return (mysql의 auto_increment는 sequence테이블에서만 사용)
|
||||
* @brief Return sequence value incremented by 1(auto_increment is used in sequence table only in MySQL)
|
||||
**/
|
||||
function getNextSequence() {
|
||||
$query = sprintf("insert into `%ssequence` (seq) values ('0')", $this->prefix);
|
||||
|
|
@ -199,7 +189,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief mysql old password를 가져오는 함수 (mysql에서만 사용)
|
||||
* @brief Function to obtain mysql old password(mysql only)
|
||||
**/
|
||||
function isValidOldPassword($password, $saved_password) {
|
||||
$query = sprintf("select password('%s') as password, old_password('%s') as old_password", $this->addQuotes($password), $this->addQuotes($password));
|
||||
|
|
@ -210,7 +200,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 테이블 기생성 여부 return
|
||||
* @brief Return if a table already exists
|
||||
**/
|
||||
function isTableExists($target_name) {
|
||||
$query = sprintf("show tables like '%s%s'", $this->prefix, $this->addQuotes($target_name));
|
||||
|
|
@ -221,7 +211,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블에 특정 column 추가
|
||||
* @brief Add a column to a table
|
||||
**/
|
||||
function addColumn($table_name, $column_name, $type='number', $size='', $default = '', $notnull=false) {
|
||||
$type = $this->column_type[$type];
|
||||
|
|
@ -237,7 +227,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블에 특정 column 제거
|
||||
* @brief Delete a column from a table
|
||||
**/
|
||||
function dropColumn($table_name, $column_name) {
|
||||
$query = sprintf("alter table `%s%s` drop `%s` ", $this->prefix, $table_name, $column_name);
|
||||
|
|
@ -245,7 +235,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블의 column의 정보를 return
|
||||
* @brief Return column information of a table
|
||||
**/
|
||||
function isColumnExists($table_name, $column_name) {
|
||||
$query = sprintf("show fields from `%s%s`", $this->prefix, $table_name);
|
||||
|
|
@ -263,7 +253,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블에 특정 인덱스 추가
|
||||
* @brief Add an index to a table
|
||||
* $target_columns = array(col1, col2)
|
||||
* $is_unique? unique : none
|
||||
**/
|
||||
|
|
@ -275,7 +265,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블의 특정 인덱스 삭제
|
||||
* @brief Drop an index from a table
|
||||
**/
|
||||
function dropIndex($table_name, $index_name, $is_unique = false) {
|
||||
$query = sprintf("alter table `%s%s` drop index `%s`", $this->prefix, $table_name, $index_name);
|
||||
|
|
@ -284,7 +274,7 @@
|
|||
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블의 index 정보를 return
|
||||
* @brief Return index information of a table
|
||||
**/
|
||||
function isIndexExists($table_name, $index_name) {
|
||||
//$query = sprintf("show indexes from %s%s where key_name = '%s' ", $this->prefix, $table_name, $index_name);
|
||||
|
|
@ -302,24 +292,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
|
||||
|
|
@ -329,8 +319,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;
|
||||
$table_name = $this->prefix.$table_name;
|
||||
|
|
@ -386,7 +375,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 조건문 작성하여 return
|
||||
* @brief Return conditional clause
|
||||
**/
|
||||
function getCondition($output) {
|
||||
if(!$output->conditions) return;
|
||||
|
|
@ -429,15 +418,14 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @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'];
|
||||
|
|
@ -466,15 +454,14 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief updateAct 처리
|
||||
* @brief Handle updateAct
|
||||
**/
|
||||
function _executeUpdateAct($output) {
|
||||
// 테이블 정리
|
||||
// List tables
|
||||
foreach($output->tables as $key => $val) {
|
||||
$table_list[] = '`'.$this->prefix.$val.'` as '.$key;
|
||||
}
|
||||
|
||||
// 컬럼 정리
|
||||
// List columns
|
||||
foreach($output->columns as $key => $val) {
|
||||
if(!isset($val['value'])) continue;
|
||||
$name = $val['name'];
|
||||
|
|
@ -487,8 +474,7 @@
|
|||
$column_list[] = sprintf("`%s` = %s", $name, $value);
|
||||
}
|
||||
}
|
||||
|
||||
// 조건절 정리
|
||||
// List the conditional clause
|
||||
$condition = $this->getCondition($output);
|
||||
|
||||
$query = sprintf("update %s set %s %s", implode(',',$table_list), implode(',',$column_list), $condition);
|
||||
|
|
@ -497,15 +483,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);
|
||||
|
|
@ -514,13 +499,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;
|
||||
|
|
@ -584,8 +569,7 @@
|
|||
$condition = $this->getCondition($output);
|
||||
|
||||
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)) {
|
||||
|
|
@ -633,7 +617,7 @@
|
|||
|
||||
$query = sprintf("select %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('%s limit %d', $query, $output->list_count['value']);
|
||||
|
||||
$query .= (__DEBUG_QUERY__&1 && $output->query_id)?sprintf(' '.$this->comment_syntax,$this->query_id):'';
|
||||
|
|
@ -656,16 +640,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
|
||||
$count_condition = count($output->groups) ? sprintf('%s group by %s', $condition, implode(', ', $output->groups)) : $condition;
|
||||
$count_query = sprintf("select count(*) as count from %s %s %s", implode(', ', $table_list), implode(' ', $left_join), $count_condition);
|
||||
if (count($output->groups)) $count_query = sprintf('select count(*) as count from (%s) xet', $count_query);
|
||||
|
|
@ -681,16 +665,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
|
||||
if($output->order) {
|
||||
$conditions = $this->getConditionList($output);
|
||||
if(!in_array('list_order', $conditions) && !in_array('update_order', $conditions)) {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
/**
|
||||
* @class DBMysql_innodb
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief MySQL DBMS를 이용하기 위한 class
|
||||
* @brief class to use MySQL DBMS
|
||||
* @version 0.1
|
||||
*
|
||||
* mysql innodb handling class
|
||||
|
|
@ -29,7 +29,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief DB접속 해제
|
||||
* @brief DB disconnection
|
||||
**/
|
||||
function close() {
|
||||
if(!$this->isConnected()) return;
|
||||
|
|
@ -38,7 +38,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 트랜잭션 시작
|
||||
* @brief Begin transaction
|
||||
**/
|
||||
function begin() {
|
||||
if(!$this->isConnected() || $this->transaction_started) return;
|
||||
|
|
@ -47,7 +47,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 롤백
|
||||
* @brief Rollback
|
||||
**/
|
||||
function rollback() {
|
||||
if(!$this->isConnected() || !$this->transaction_started) return;
|
||||
|
|
@ -56,7 +56,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 커밋
|
||||
* @brief Commits
|
||||
**/
|
||||
function commit($force = false) {
|
||||
if(!$force && (!$this->isConnected() || !$this->transaction_started)) return;
|
||||
|
|
@ -65,35 +65,30 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief : 쿼리문의 실행 및 결과의 fetch 처리
|
||||
* @brief : Run a query and fetch the result
|
||||
*
|
||||
* query : query문 실행하고 result return\n
|
||||
* fetch : reutrn 된 값이 없으면 NULL\n
|
||||
* rows이면 array object\n
|
||||
* row이면 object\n
|
||||
* query: run a query and return the result \n
|
||||
* fetch: NULL if no value is returned \n
|
||||
* array object if rows are returned \n
|
||||
* object if a row is returned \n
|
||||
* return\n
|
||||
**/
|
||||
function _query($query) {
|
||||
if(!$this->isConnected()) return;
|
||||
|
||||
// 쿼리 시작을 알림
|
||||
// Notify to start a query execution
|
||||
$this->actStart($query);
|
||||
|
||||
// 쿼리 문 실행
|
||||
// Run the query statement
|
||||
$result = @mysql_query($query, $this->fd);
|
||||
|
||||
// 오류 체크
|
||||
// Error Check
|
||||
if(mysql_error($this->fd)) $this->setError(mysql_errno($this->fd), mysql_error($this->fd));
|
||||
|
||||
// 쿼리 실행 종료를 알림
|
||||
// Notify to complete a query execution
|
||||
$this->actFinish();
|
||||
|
||||
// 결과 리턴
|
||||
// Return result
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
|
|
@ -103,8 +98,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;
|
||||
$table_name = $this->prefix.$table_name;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
* @class DBMysqli
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief MySQL DBMS를 mysqli_* 로 이용하기 위한 class
|
||||
* @brief Class to use MySQL DBMS as mysqli_*
|
||||
* @version 0.1
|
||||
*
|
||||
* mysql handling class
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 설치 가능 여부를 return
|
||||
* @brief Return if it is installable
|
||||
**/
|
||||
function isSupported() {
|
||||
if(!function_exists('mysqli_connect')) return false;
|
||||
|
|
@ -37,13 +37,12 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief DB 접속
|
||||
* @brief DB Connection
|
||||
**/
|
||||
function _connect() {
|
||||
// db 정보가 없으면 무시
|
||||
// Ignore if no DB information exists
|
||||
if(!$this->hostname || !$this->userid || !$this->password || !$this->database) return;
|
||||
|
||||
// 접속시도
|
||||
// Attempt to connect
|
||||
if($this->port){
|
||||
$this->fd = @mysqli_connect($this->hostname, $this->userid, $this->password, $this->database, $this->port);
|
||||
}else{
|
||||
|
|
@ -55,14 +54,13 @@
|
|||
return;
|
||||
}
|
||||
mysqli_set_charset($this->fd,'utf8');
|
||||
|
||||
// 접속체크
|
||||
// Check connections
|
||||
$this->is_connected = true;
|
||||
$this->password = md5($this->password);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DB접속 해제
|
||||
* @brief DB disconnection
|
||||
**/
|
||||
function close() {
|
||||
if(!$this->isConnected()) return;
|
||||
|
|
@ -70,7 +68,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 쿼리에서 입력되는 문자열 변수들의 quotation 조절
|
||||
* @brief Add quotes on the string variables in a query
|
||||
**/
|
||||
function addQuotes($string) {
|
||||
if(version_compare(PHP_VERSION, "5.9.0", "<") && get_magic_quotes_gpc()) $string = stripslashes(str_replace("\\","\\\\",$string));
|
||||
|
|
@ -79,32 +77,29 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief : 쿼리문의 실행 및 결과의 fetch 처리
|
||||
* @brief : Run a query and fetch the result
|
||||
*
|
||||
* query : query문 실행하고 result return\n
|
||||
* fetch : reutrn 된 값이 없으면 NULL\n
|
||||
* rows이면 array object\n
|
||||
* row이면 object\n
|
||||
* query: run a query and return the result \n
|
||||
* fetch: NULL if no value is returned \n
|
||||
* array object if rows are returned \n
|
||||
* object if a row is returned \n
|
||||
* return\n
|
||||
**/
|
||||
function _query($query) {
|
||||
if(!$this->isConnected()) return;
|
||||
|
||||
// 쿼리 시작을 알림
|
||||
// Notify to start a query execution
|
||||
$this->actStart($query);
|
||||
|
||||
// 쿼리 문 실행
|
||||
// Run the query statement
|
||||
$result = mysqli_query($this->fd,$query);
|
||||
// 오류 체크
|
||||
// Error Check
|
||||
$error = mysqli_error($this->fd);
|
||||
if($error){
|
||||
$this->setError(mysqli_errno($this->fd), $error);
|
||||
}
|
||||
|
||||
// 쿼리 실행 종료를 알림
|
||||
// Notify to complete a query execution
|
||||
$this->actFinish();
|
||||
|
||||
// 결과 리턴
|
||||
// Return result
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,34 +2,34 @@
|
|||
/**
|
||||
* @class DBPostgreSQL
|
||||
* @author ioseph (ioseph@postgresql.kr) updated by yoonjong.joh@gmail.com
|
||||
* @brief MySQL DBMS를 이용하기 위한 class
|
||||
* @brief Class to use PostgreSQL DBMS
|
||||
* @version 0.2
|
||||
*
|
||||
* postgresql handling class
|
||||
* 2009.02.10 update 와 delete query를 실행할때 table 이름에 alias 사용하는 것을 없앰. 지원 안함
|
||||
* order by clause를 실행할때 함수를 실행 하는 부분을 column alias로 대체.
|
||||
* 2009.02.11 dropColumn() function이 추가
|
||||
* 2009.02.13 addColumn() 함수 변경
|
||||
* 2009.02.10 update and delete query for the table name at runtime, eliminating the alias to use. Not Supported
|
||||
* when running order by clause column alias to run a function to replace parts.
|
||||
* 2009.02.11 dropColumn() function added
|
||||
* 2009.02.13 addColumn() function changes
|
||||
**/
|
||||
|
||||
class DBPostgresql extends DB
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief PostgreSQL DB에 접속하기 위한 정보
|
||||
* @brief Connection information for PostgreSQL DB
|
||||
**/
|
||||
var $hostname = '127.0.0.1'; ///< hostname
|
||||
var $userid = null; ///< user id
|
||||
var $password = null; ///< password
|
||||
var $database = null; ///< database
|
||||
var $prefix = 'xe'; ///< XE에서 사용할 테이블들의 prefix (한 DB에서 여러개의 XE설치 가능)
|
||||
var $prefix = 'xe'; // / <prefix of a tablename (One or more XEs can be installed in a single DB)
|
||||
var $comment_syntax = '/* %s */';
|
||||
|
||||
/**
|
||||
* @brief postgresql에서 사용될 column type
|
||||
* @brief column type used in postgresql
|
||||
*
|
||||
* column_type은 schema/query xml에서 공통 선언된 type을 이용하기 때문에
|
||||
* 각 DBMS에 맞게 replace 해주어야 한다
|
||||
* Becasue a common column type in schema/query xml is used for colum_type,
|
||||
* it should be replaced properly for each DBMS
|
||||
**/
|
||||
var $column_type = array(
|
||||
'bignumber' => 'bigint',
|
||||
|
|
@ -60,7 +60,7 @@ class DBPostgresql extends DB
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 설치 가능 여부를 return
|
||||
* @brief Return if it is installable
|
||||
**/
|
||||
function isSupported()
|
||||
{
|
||||
|
|
@ -70,7 +70,7 @@ class DBPostgresql extends DB
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief DB정보 설정 및 connect/ close
|
||||
* @brief DB settings and connect/close
|
||||
**/
|
||||
function _setDBInfo()
|
||||
{
|
||||
|
|
@ -86,40 +86,36 @@ class DBPostgresql extends DB
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief DB 접속
|
||||
* @brief DB Connection
|
||||
**/
|
||||
function _connect()
|
||||
{
|
||||
// pg용 connection string
|
||||
// the connection string for PG
|
||||
$conn_string = "";
|
||||
|
||||
// db 정보가 없으면 무시
|
||||
// Ignore if no DB information exists
|
||||
if (!$this->hostname || !$this->userid || !$this->database)
|
||||
return;
|
||||
|
||||
// connection string 만들기
|
||||
// Create connection string
|
||||
$conn_string .= ($this->hostname) ? " host=$this->hostname" : "";
|
||||
$conn_string .= ($this->userid) ? " user=$this->userid" : "";
|
||||
$conn_string .= ($this->password) ? " password=$this->password" : "";
|
||||
$conn_string .= ($this->database) ? " dbname=$this->database" : "";
|
||||
$conn_string .= ($this->port) ? " port=$this->port" : "";
|
||||
|
||||
// 접속시도
|
||||
// Attempt to connect
|
||||
$this->fd = @pg_connect($conn_string);
|
||||
if (!$this->fd || pg_connection_status($this->fd) != PGSQL_CONNECTION_OK) {
|
||||
$this->setError(-1, "CONNECTION FAILURE");
|
||||
return;
|
||||
}
|
||||
|
||||
// 접속체크
|
||||
// Check connections
|
||||
$this->is_connected = true;
|
||||
$this->password = md5($this->password);
|
||||
// utf8임을 지정
|
||||
// Set utf8
|
||||
//$this ->_query('set client_encoding to uhc');
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DB접속 해제
|
||||
* @brief DB disconnection
|
||||
**/
|
||||
function close()
|
||||
{
|
||||
|
|
@ -129,7 +125,7 @@ class DBPostgresql extends DB
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 쿼리에서 입력되는 문자열 변수들의 quotation 조절
|
||||
* @brief Add quotes on the string variables in a query
|
||||
**/
|
||||
function addQuotes($string)
|
||||
{
|
||||
|
|
@ -141,7 +137,7 @@ class DBPostgresql extends DB
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 트랜잭션 시작
|
||||
* @brief Begin transaction
|
||||
**/
|
||||
function begin()
|
||||
{
|
||||
|
|
@ -152,7 +148,7 @@ class DBPostgresql extends DB
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 롤백
|
||||
* @brief Rollback
|
||||
**/
|
||||
function rollback()
|
||||
{
|
||||
|
|
@ -163,7 +159,7 @@ class DBPostgresql extends DB
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 커밋
|
||||
* @brief Commits
|
||||
**/
|
||||
function commit()
|
||||
{
|
||||
|
|
@ -174,12 +170,12 @@ class DBPostgresql extends DB
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief : 쿼리문의 실행 및 결과의 fetch 처리
|
||||
* @brief : Run a query and fetch the result
|
||||
*
|
||||
* query : query문 실행하고 result return\n
|
||||
* fetch : reutrn 된 값이 없으면 NULL\n
|
||||
* rows이면 array object\n
|
||||
* row이면 object\n
|
||||
* query: run a query and return the result \n
|
||||
* fetch: NULL if no value is returned \n
|
||||
* array object if rows are returned \n
|
||||
* object if a row is returned \n
|
||||
* return\n
|
||||
**/
|
||||
function _query($query)
|
||||
|
|
@ -208,16 +204,12 @@ class DBPostgresql extends DB
|
|||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// 쿼리 시작을 알림
|
||||
// Notify to start a query execution
|
||||
$this->actStart($query);
|
||||
$arr = array('Hello', 'World!', 'Beautiful', 'Day!');
|
||||
|
||||
|
||||
// 쿼리 문 실행
|
||||
// Run the query statement
|
||||
$result = @pg_query($this->fd, $query);
|
||||
|
||||
// 오류 체크
|
||||
// Error Check
|
||||
if (!$result) {
|
||||
// var_dump($l_query_array);
|
||||
//var_dump($query);
|
||||
|
|
@ -225,16 +217,14 @@ class DBPostgresql extends DB
|
|||
//var_dump(debug_backtrace());
|
||||
$this->setError(1, pg_last_error($this->fd));
|
||||
}
|
||||
|
||||
// 쿼리 실행 종료를 알림
|
||||
// Notify to complete a query execution
|
||||
$this->actFinish();
|
||||
|
||||
// 결과 리턴
|
||||
// Return result
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 결과를 fetch
|
||||
* @brief Fetch results
|
||||
**/
|
||||
function _fetch($result)
|
||||
{
|
||||
|
|
@ -249,7 +239,7 @@ class DBPostgresql extends DB
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 1씩 증가되는 sequence값을 return (postgresql의 auto_increment는 sequence테이블에서만 사용)
|
||||
* @brief Return sequence value incremented by 1(in postgresql, auto_increment is used in the sequence table only)
|
||||
**/
|
||||
function getNextSequence()
|
||||
{
|
||||
|
|
@ -260,7 +250,7 @@ class DBPostgresql extends DB
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 테이블 기생성 여부 return
|
||||
* @brief Return if a table already exists
|
||||
**/
|
||||
function isTableExists($target_name)
|
||||
{
|
||||
|
|
@ -277,7 +267,7 @@ class DBPostgresql extends DB
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블에 특정 column 추가
|
||||
* @brief Add a column to a table
|
||||
**/
|
||||
function addColumn($table_name, $column_name, $type = 'number', $size = '', $default =
|
||||
NULL, $notnull = false)
|
||||
|
|
@ -309,7 +299,7 @@ class DBPostgresql extends DB
|
|||
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블의 column의 정보를 return
|
||||
* @brief Return column information of a table
|
||||
**/
|
||||
function isColumnExists($table_name, $column_name)
|
||||
{
|
||||
|
|
@ -329,7 +319,7 @@ class DBPostgresql extends DB
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블에 특정 인덱스 추가
|
||||
* @brief Add an index to a table
|
||||
* $target_columns = array(col1, col2)
|
||||
* $is_unique? unique : none
|
||||
**/
|
||||
|
|
@ -340,8 +330,7 @@ class DBPostgresql extends DB
|
|||
|
||||
if (strpos($table_name, $this->prefix) === false)
|
||||
$table_name = $this->prefix . $table_name;
|
||||
|
||||
// index_name의 경우 앞에 table이름을 붙여줘서 중복을 피함
|
||||
// Use a tablename before an index name to avoid defining the same index
|
||||
$index_name = $table_name . $index_name;
|
||||
|
||||
$query = sprintf("create %s index %s on %s (%s);", $is_unique ? 'unique' : '', $index_name,
|
||||
|
|
@ -350,7 +339,7 @@ class DBPostgresql extends DB
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블에 특정 column 제거
|
||||
* @brief Delete a column from a table
|
||||
**/
|
||||
function dropColumn($table_name, $column_name)
|
||||
{
|
||||
|
|
@ -359,14 +348,13 @@ class DBPostgresql extends DB
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블의 특정 인덱스 삭제
|
||||
* @brief Drop an index from a table
|
||||
**/
|
||||
function dropIndex($table_name, $index_name, $is_unique = false)
|
||||
{
|
||||
if (strpos($table_name, $this->prefix) === false)
|
||||
$table_name = $this->prefix . $table_name;
|
||||
|
||||
// index_name의 경우 앞에 table이름을 붙여줘서 중복을 피함
|
||||
// Use a tablename before an index name to avoid defining the same index
|
||||
$index_name = $table_name . $index_name;
|
||||
|
||||
$query = sprintf("drop index %s", $index_name);
|
||||
|
|
@ -375,14 +363,13 @@ class DBPostgresql extends DB
|
|||
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블의 index 정보를 return
|
||||
* @brief Return index information of a table
|
||||
**/
|
||||
function isIndexExists($table_name, $index_name)
|
||||
{
|
||||
if (strpos($table_name, $this->prefix) === false)
|
||||
$table_name = $this->prefix . $table_name;
|
||||
|
||||
// index_name의 경우 앞에 table이름을 붙여줘서 중복을 피함
|
||||
// Use a tablename before an index name to avoid defining the same index
|
||||
$index_name = $table_name . $index_name;
|
||||
|
||||
//$query = sprintf("show indexes from %s%s where key_name = '%s' ", $this->prefix, $table_name, $index_name);
|
||||
|
|
@ -402,7 +389,7 @@ class DBPostgresql extends DB
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief xml 을 받아서 테이블을 생성
|
||||
* @brief Create a table by using xml file
|
||||
**/
|
||||
function createTableByXml($xml_doc)
|
||||
{
|
||||
|
|
@ -410,19 +397,19 @@ class DBPostgresql extends DB
|
|||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
|
|
@ -433,8 +420,7 @@ class DBPostgresql extends DB
|
|||
// xml parsing
|
||||
$oXml = new XmlParser();
|
||||
$xml_obj = $oXml->parse($xml_doc);
|
||||
|
||||
// 테이블 생성 schema 작성
|
||||
// Create a table schema
|
||||
$table_name = $xml_obj->table->attrs->name;
|
||||
|
||||
if ($table_name == 'sequence') {
|
||||
|
|
@ -508,7 +494,7 @@ class DBPostgresql extends DB
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 조건문 작성하여 return
|
||||
* @brief Return conditional clause
|
||||
**/
|
||||
function getCondition($output)
|
||||
{
|
||||
|
|
@ -564,16 +550,15 @@ class DBPostgresql extends DB
|
|||
|
||||
|
||||
/**
|
||||
* @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'];
|
||||
|
|
@ -594,17 +579,16 @@ class DBPostgresql extends DB
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief updateAct 처리
|
||||
* @brief Handle updateAct
|
||||
**/
|
||||
function _executeUpdateAct($output)
|
||||
{
|
||||
// 테이블 정리
|
||||
// List tables
|
||||
foreach ($output->tables as $key => $val) {
|
||||
//$table_list[] = $this->prefix.$val.' as '.$key;
|
||||
$table_list[] = $this->prefix . $val;
|
||||
}
|
||||
|
||||
// 컬럼 정리
|
||||
// List columns
|
||||
foreach ($output->columns as $key => $val) {
|
||||
if (!isset($val['value']))
|
||||
continue;
|
||||
|
|
@ -621,8 +605,7 @@ class DBPostgresql extends DB
|
|||
$column_list[] = sprintf("%s = %s", $name, $value);
|
||||
}
|
||||
}
|
||||
|
||||
// 조건절 정리
|
||||
// List the conditional clause
|
||||
$condition = $this->getCondition($output);
|
||||
|
||||
$query = sprintf("update %s set %s %s", implode(',', $table_list), implode(',',
|
||||
|
|
@ -632,16 +615,15 @@ class DBPostgresql extends DB
|
|||
}
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
|
@ -650,14 +632,14 @@ class DBPostgresql extends DB
|
|||
}
|
||||
|
||||
/**
|
||||
* @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;
|
||||
|
|
@ -709,8 +691,7 @@ class DBPostgresql extends DB
|
|||
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)) {
|
||||
|
|
@ -794,9 +775,9 @@ class DBPostgresql extends DB
|
|||
}
|
||||
|
||||
/**
|
||||
* @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)
|
||||
{
|
||||
|
|
@ -804,8 +785,8 @@ class DBPostgresql extends DB
|
|||
|
||||
$column_list = $output->column_list;
|
||||
/*
|
||||
// group by 절이 포함된 SELECT 쿼리의 전체 갯수를 구하기 위한 수정
|
||||
// 정상적인 동작이 확인되면 주석으로 막아둔 부분으로 대체합니다.
|
||||
// Modified to find total number of SELECT queries having group by clause
|
||||
// If it works correctly, uncomment the following codes
|
||||
//
|
||||
$count_condition = count($output->groups) ? sprintf('%s group by %s', $condition, implode(', ', $output->groups)) : $condition;
|
||||
$total_count = $this->getCountCache($output->tables, $count_condition);
|
||||
|
|
@ -820,7 +801,7 @@ class DBPostgresql extends DB
|
|||
}
|
||||
*/
|
||||
|
||||
// 전체 개수를 구함
|
||||
// Get a total count
|
||||
$count_query = sprintf("select count(*) as count from %s %s %s", implode(',', $table_list), implode(' ', $left_join), $condition);
|
||||
$count_query .= (__DEBUG_QUERY__&1 && $output->query_id)?sprintf(' '.$this->comment_syntax,$this->query_id . ' count(*)'):'';
|
||||
$result = $this->_query($count_query);
|
||||
|
|
@ -835,15 +816,14 @@ class DBPostgresql extends DB
|
|||
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
|
||||
if ($output->order) {
|
||||
$conditions = $this->getConditionList($output);
|
||||
if (!in_array('list_order', $conditions) && !in_array('update_order', $conditions)) {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* @class DBSqlite2
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief SQLite ver 2.x 를 이용하기 위한 class
|
||||
* @brief Class for using SQLite ver 2.x
|
||||
* @version 0.1
|
||||
*
|
||||
* sqlite handling class (sqlite ver 2.x)
|
||||
|
|
@ -11,17 +11,17 @@
|
|||
class DBSqlite2 extends DB {
|
||||
|
||||
/**
|
||||
* DB를 이용하기 위한 정보
|
||||
* DB information
|
||||
**/
|
||||
var $database = NULL; ///< database
|
||||
var $prefix = 'xe'; ///< XE에서 사용할 테이블들의 prefix (한 DB에서 여러개의 XE설치 가능)
|
||||
var $prefix = 'xe'; // / <prefix of a tablename (One or more XEs can be installed in a single DB)
|
||||
var $comment_syntax = '/* %s */';
|
||||
|
||||
/**
|
||||
* @brief sqlite 에서 사용될 column type
|
||||
* @brief sqlite column type used in
|
||||
*
|
||||
* column_type은 schema/query xml에서 공통 선언된 type을 이용하기 때문에
|
||||
* 각 DBMS에 맞게 replace 해주어야 한다
|
||||
* Becasue a common column type in schema/query xml is used for colum_type,
|
||||
* it should be replaced properly for each DBMS
|
||||
**/
|
||||
var $column_type = array(
|
||||
'bignumber' => 'INTEGER',
|
||||
|
|
@ -51,7 +51,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 설치 가능 여부를 return
|
||||
* @brief Return if it is installable
|
||||
**/
|
||||
function isSupported() {
|
||||
if(!function_exists('sqlite_open')) return false;
|
||||
|
|
@ -59,7 +59,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief DB정보 설정 및 connect/ close
|
||||
* @brief DB settings and connect/close
|
||||
**/
|
||||
function _setDBInfo() {
|
||||
$db_info = Context::getDBInfo();
|
||||
|
|
@ -69,27 +69,25 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief DB 접속
|
||||
* @brief DB Connection
|
||||
**/
|
||||
function _connect() {
|
||||
// db 정보가 없으면 무시
|
||||
// Ignore if no DB information exists
|
||||
if(!$this->database) return;
|
||||
|
||||
// 데이터 베이스 파일 접속 시도
|
||||
// Attempt to access the database file
|
||||
$this->fd = sqlite_open($this->database, 0666, $error);
|
||||
if(!file_exists($this->database) || $error) {
|
||||
$this->setError(-1,$error);
|
||||
$this->is_connected = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// 접속체크
|
||||
// Check connections
|
||||
$this->is_connected = true;
|
||||
$this->password = md5($this->password);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DB접속 해제
|
||||
* @brief DB disconnection
|
||||
**/
|
||||
function close() {
|
||||
if(!$this->isConnected()) return;
|
||||
|
|
@ -97,7 +95,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 트랜잭션 시작
|
||||
* @brief Begin transaction
|
||||
**/
|
||||
function begin() {
|
||||
if(!$this->is_connected || $this->transaction_started) return;
|
||||
|
|
@ -105,7 +103,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 롤백
|
||||
* @brief Rollback
|
||||
**/
|
||||
function rollback() {
|
||||
if(!$this->is_connected || !$this->transaction_started) return;
|
||||
|
|
@ -114,7 +112,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 커밋
|
||||
* @brief Commits
|
||||
**/
|
||||
function commit($force = false) {
|
||||
if(!$force && (!$this->isConnected() || !$this->transaction_started)) return;
|
||||
|
|
@ -124,7 +122,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 쿼리에서 입력되는 문자열 변수들의 quotation 조절
|
||||
* @brief Add quotes on the string variables in a query
|
||||
**/
|
||||
function addQuotes($string) {
|
||||
if(version_compare(PHP_VERSION, "5.9.0", "<") && get_magic_quotes_gpc()) $string = stripslashes(str_replace("\\","\\\\",$string));
|
||||
|
|
@ -133,34 +131,30 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief : 쿼리문의 실행 및 결과의 fetch 처리
|
||||
* @brief : Run a query and fetch the result
|
||||
*
|
||||
* query : query문 실행하고 result return\n
|
||||
* fetch : reutrn 된 값이 없으면 NULL\n
|
||||
* rows이면 array object\n
|
||||
* row이면 object\n
|
||||
* query: run a query and return the result \n
|
||||
* fetch: NULL if no value is returned \n
|
||||
* array object if rows are returned \n
|
||||
* object if a row is returned \n
|
||||
* return\n
|
||||
**/
|
||||
function _query($query) {
|
||||
if(!$this->isConnected()) return;
|
||||
|
||||
// 쿼리 시작을 알림
|
||||
// Notify to start a query execution
|
||||
$this->actStart($query);
|
||||
|
||||
// 쿼리 문 실행
|
||||
// Run the query statement
|
||||
$result = @sqlite_query($query, $this->fd);
|
||||
|
||||
// 오류 체크
|
||||
// Error Check
|
||||
if(sqlite_last_error($this->fd)) $this->setError(sqlite_last_error($this->fd), sqlite_error_string(sqlite_last_error($this->fd)));
|
||||
|
||||
// 쿼리 실행 알림
|
||||
// Notify to complete a query execution
|
||||
$this->actFinish();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 결과를 fetch
|
||||
* @brief Fetch results
|
||||
**/
|
||||
function _fetch($result) {
|
||||
if($this->isError() || !$result) return;
|
||||
|
|
@ -180,7 +174,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 1씩 증가되는 sequence값을 return
|
||||
* @brief Return the sequence value is incremented by 1
|
||||
**/
|
||||
function getNextSequence() {
|
||||
$query = sprintf("insert into %ssequence (seq) values ('')", $this->prefix);
|
||||
|
|
@ -195,7 +189,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 테이블 기생성 여부 return
|
||||
* @brief Return if a table already exists
|
||||
**/
|
||||
function isTableExists($target_name) {
|
||||
$query = sprintf('pragma table_info(%s%s)', $this->prefix, $this->addQuotes($target_name));
|
||||
|
|
@ -205,7 +199,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블에 특정 column 추가
|
||||
* @brief Add a column to a table
|
||||
**/
|
||||
function addColumn($table_name, $column_name, $type='number', $size='', $default = '', $notnull=false) {
|
||||
$type = $this->column_type[$type];
|
||||
|
|
@ -221,7 +215,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블에 특정 column 제거
|
||||
* @brief Delete a column from a table
|
||||
**/
|
||||
function dropColumn($table_name, $column_name) {
|
||||
$query = sprintf("alter table %s%s drop column %s ", $this->prefix, $table_name, $column_name);
|
||||
|
|
@ -229,7 +223,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블의 column의 정보를 return
|
||||
* @brief Return column information of a table
|
||||
**/
|
||||
function isColumnExists($table_name, $column_name) {
|
||||
$query = sprintf("pragma table_info(%s%s)", $this->prefix, $table_name);
|
||||
|
|
@ -246,7 +240,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블에 특정 인덱스 추가
|
||||
* @brief Add an index to a table
|
||||
* $target_columns = array(col1, col2)
|
||||
* $is_unique? unique : none
|
||||
**/
|
||||
|
|
@ -261,7 +255,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블의 특정 인덱스 삭제
|
||||
* @brief Drop an index from a table
|
||||
**/
|
||||
function dropIndex($table_name, $index_name, $is_unique = false) {
|
||||
$key_name = sprintf('%s%s_%s', $this->prefix, $table_name, $index_name);
|
||||
|
|
@ -270,7 +264,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블의 index 정보를 return
|
||||
* @brief Return index information of a table
|
||||
**/
|
||||
function isIndexExists($table_name, $index_name) {
|
||||
$key_name = sprintf('%s%s_%s', $this->prefix, $table_name, $index_name);
|
||||
|
|
@ -282,24 +276,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
|
||||
|
|
@ -309,8 +303,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;
|
||||
$table_name = $this->prefix.$table_name;
|
||||
|
|
@ -371,7 +364,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 조건문 작성하여 return
|
||||
* @brief Return conditional clause
|
||||
**/
|
||||
function getCondition($output) {
|
||||
if(!$output->conditions) return;
|
||||
|
|
@ -415,15 +408,14 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @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'];
|
||||
|
|
@ -441,18 +433,16 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief updateAct 처리
|
||||
* @brief Handle updateAct
|
||||
**/
|
||||
function _executeUpdateAct($output) {
|
||||
$table_count = count(array_values($output->tables));
|
||||
|
||||
// 대상 테이블이 1개일 경우
|
||||
// If one day the destination table
|
||||
if($table_count == 1) {
|
||||
// 테이블 정리
|
||||
// List tables
|
||||
list($target_table) = array_values($output->tables);
|
||||
$target_table = $this->prefix.$target_table;
|
||||
|
||||
// 컬럼 정리
|
||||
// List columns
|
||||
foreach($output->columns as $key => $val) {
|
||||
if(!isset($val['value'])) continue;
|
||||
$name = $val['name'];
|
||||
|
|
@ -465,27 +455,23 @@
|
|||
$column_list[] = sprintf("%s = %s", $name, $value);
|
||||
}
|
||||
}
|
||||
|
||||
// 조건절 정리
|
||||
// List the conditional clause
|
||||
$condition = $this->getCondition($output);
|
||||
|
||||
$query = sprintf("update %s set %s %s", $target_table, implode(',',$column_list), $condition);
|
||||
|
||||
// 대상 테이블이 2개일 경우 (sqlite에서 update 테이블을 1개 이상 지정 못해서 이렇게 꽁수로... 다른 방법이 있으려나..)
|
||||
// trick to handle if targt table to update is more than one (sqlite doesn't support update to multi-tables)
|
||||
} elseif($table_count == 2) {
|
||||
// 테이블 정리
|
||||
// List tables
|
||||
foreach($output->tables as $key => $val) {
|
||||
$table_list[$val] = $this->prefix.$key;
|
||||
}
|
||||
list($source_table, $target_table) = array_values($table_list);
|
||||
|
||||
// 조건절 정리
|
||||
// List the conditional clause
|
||||
$condition = $this->getCondition($output);
|
||||
foreach($table_list as $key => $val) {
|
||||
$condition = eregi_replace($key.'\\.', $val.'.', $condition);
|
||||
}
|
||||
|
||||
// 컬럼 정리
|
||||
// List columns
|
||||
foreach($output->columns as $key => $val) {
|
||||
if(!isset($val['value'])) continue;
|
||||
$name = $val['name'];
|
||||
|
|
@ -507,15 +493,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);
|
||||
|
|
@ -524,13 +509,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;
|
||||
|
|
@ -573,8 +558,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)) {
|
||||
|
|
@ -597,8 +581,7 @@
|
|||
}
|
||||
if(count($index_list)) $query .= ' order by '.implode(',',$index_list);
|
||||
}
|
||||
|
||||
// list_count를 사용할 경우 적용
|
||||
// Apply when using list_count
|
||||
if($output->list_count['value']) $query = sprintf('%s limit %d', $query, $output->list_count['value']);
|
||||
|
||||
$query .= (__DEBUG_QUERY__&1 && $output->query_id)?sprintf(' '.$this->comment_syntax,$this->query_id):'';
|
||||
|
|
@ -620,17 +603,17 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @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;
|
||||
/*
|
||||
// group by 절이 포함된 SELECT 쿼리의 전체 갯수를 구하기 위한 수정
|
||||
// 정상적인 동작이 확인되면 주석으로 막아둔 부분으로 대체합니다.
|
||||
// Modified to find total number of SELECT queries having group by clause
|
||||
// If it works correctly, uncomment the following codes
|
||||
//
|
||||
$count_condition = count($output->groups) ? sprintf('%s group by %s', $condition, implode(', ', $output->groups)) : $condition;
|
||||
$total_count = $this->getCountCache($output->tables, $count_condition);
|
||||
|
|
@ -644,8 +627,7 @@
|
|||
$this->putCountCache($output->tables, $count_condition, $total_count);
|
||||
}
|
||||
*/
|
||||
|
||||
// 전체 개수를 구함
|
||||
// Get a total count
|
||||
$count_query = sprintf("select count(*) as count from %s %s %s", implode(',',$table_list),implode(' ',$left_join), $condition);
|
||||
$count_query .= (__DEBUG_QUERY__&1 && $output->query_id)?sprintf(' '.$this->comment_syntax,$this->query_id . ' count(*)'):'';
|
||||
$result = $this->_query($count_query);
|
||||
|
|
@ -658,16 +640,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
|
||||
if($output->order) {
|
||||
$conditions = $this->getConditionList($output);
|
||||
if(!in_array('list_order', $conditions) && !in_array('update_order', $conditions)) {
|
||||
|
|
|
|||
|
|
@ -2,21 +2,21 @@
|
|||
/**
|
||||
* @class DBSqlite3_pdo
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief SQLite3를 PDO로 이용하여 class
|
||||
* @brief class to use SQLite3 with PDO
|
||||
* @version 0.1
|
||||
**/
|
||||
|
||||
class DBSqlite3_pdo extends DB {
|
||||
|
||||
/**
|
||||
* DB를 이용하기 위한 정보
|
||||
* DB information
|
||||
**/
|
||||
var $database = NULL; ///< database
|
||||
var $prefix = 'xe'; ///< XE에서 사용할 테이블들의 prefix (한 DB에서 여러개의 XE 설치 가능)
|
||||
var $prefix = 'xe'; // /< prefix of a tablename (many XEs can be installed in a single DB)
|
||||
var $comment_syntax = '/* %s */';
|
||||
|
||||
/**
|
||||
* PDO 사용시 필요한 변수들
|
||||
* Variables for using PDO
|
||||
**/
|
||||
var $handler = NULL;
|
||||
var $stmt = NULL;
|
||||
|
|
@ -24,10 +24,10 @@
|
|||
var $bind_vars = array();
|
||||
|
||||
/**
|
||||
* @brief sqlite3 에서 사용될 column type
|
||||
* @brief column type used in sqlite3
|
||||
*
|
||||
* column_type은 schema/query xml에서 공통 선언된 type을 이용하기 때문에
|
||||
* 각 DBMS에 맞게 replace 해주어야 한다
|
||||
* column_type should be replaced for each DBMS properly
|
||||
* because column_type uses a commonly defined type in schema/query xml files
|
||||
**/
|
||||
var $column_type = array(
|
||||
'bignumber' => 'INTEGER',
|
||||
|
|
@ -57,14 +57,14 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 설치 가능 여부를 return
|
||||
* @brief Return if installable
|
||||
**/
|
||||
function isSupported() {
|
||||
return class_exists('PDO');
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DB정보 설정 및 connect/ close
|
||||
* @brief DB settings and connect/close
|
||||
**/
|
||||
function _setDBInfo() {
|
||||
$db_info = Context::getDBInfo();
|
||||
|
|
@ -74,13 +74,13 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief DB 접속
|
||||
* @brief DB Connection
|
||||
**/
|
||||
function _connect() {
|
||||
// db 정보가 없으면 무시
|
||||
// override if db information not exists
|
||||
if(!$this->database) return;
|
||||
|
||||
// 데이터 베이스 파일 접속 시도
|
||||
// Attempt to access the database file
|
||||
try {
|
||||
// PDO is only supported with PHP5,
|
||||
// so it is allowed to use try~catch statment in this class.
|
||||
|
|
@ -91,13 +91,13 @@
|
|||
return;
|
||||
}
|
||||
|
||||
// 접속체크
|
||||
// Check connections
|
||||
$this->is_connected = true;
|
||||
$this->password = md5($this->password);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DB접속 해제
|
||||
* @brief disconnect to DB
|
||||
**/
|
||||
function close() {
|
||||
if(!$this->is_connected) return;
|
||||
|
|
@ -105,7 +105,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 트랜잭션 시작
|
||||
* @brief Begin a transaction
|
||||
**/
|
||||
function begin() {
|
||||
if(!$this->is_connected || $this->transaction_started) return;
|
||||
|
|
@ -113,7 +113,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 롤백
|
||||
* @brief Rollback
|
||||
**/
|
||||
function rollback() {
|
||||
if(!$this->is_connected || !$this->transaction_started) return;
|
||||
|
|
@ -122,7 +122,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 커밋
|
||||
* @brief Commit
|
||||
**/
|
||||
function commit($force = false) {
|
||||
if(!$force && (!$this->is_connected || !$this->transaction_started)) return;
|
||||
|
|
@ -131,7 +131,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 쿼리에서 입력되는 문자열 변수들의 quotation 조절
|
||||
* @brief Add or change quotes to the query string variables
|
||||
**/
|
||||
function addQuotes($string) {
|
||||
if(version_compare(PHP_VERSION, "5.9.0", "<") && get_magic_quotes_gpc()) $string = stripslashes(str_replace("\\","\\\\",$string));
|
||||
|
|
@ -140,12 +140,12 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief : 쿼리문의 prepare
|
||||
* @brief : Prepare a query statement
|
||||
**/
|
||||
function _prepare($query) {
|
||||
if(!$this->is_connected) return;
|
||||
|
||||
// 쿼리 시작을 알림
|
||||
// notify to start a query execution
|
||||
$this->actStart($query);
|
||||
|
||||
$this->stmt = $this->handler->prepare($query);
|
||||
|
|
@ -159,7 +159,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief : stmt에 binding params
|
||||
* @brief : Binding params in stmt
|
||||
**/
|
||||
function _bind($val) {
|
||||
if(!$this->is_connected || !$this->stmt) return;
|
||||
|
|
@ -170,7 +170,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief : prepare된 쿼리의 execute
|
||||
* @brief : execute the prepared statement
|
||||
**/
|
||||
function _execute() {
|
||||
if(!$this->is_connected || !$this->stmt) return;
|
||||
|
|
@ -200,7 +200,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 1씩 증가되는 sequence값을 return
|
||||
* @brief Return the sequence value incremented by 1
|
||||
**/
|
||||
function getNextSequence() {
|
||||
$query = sprintf("insert into %ssequence (seq) values (NULL)", $this->prefix);
|
||||
|
|
@ -217,7 +217,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 테이블 기생성 여부 return
|
||||
* @brief return if the table already exists
|
||||
**/
|
||||
function isTableExists($target_name) {
|
||||
$query = sprintf('pragma table_info(%s%s)', $this->prefix, $target_name);
|
||||
|
|
@ -227,7 +227,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블에 특정 column 추가
|
||||
* @brief Add a column to a table
|
||||
**/
|
||||
function addColumn($table_name, $column_name, $type='number', $size='', $default = '', $notnull=false) {
|
||||
$type = $this->column_type[$type];
|
||||
|
|
@ -244,7 +244,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블에 특정 column 제거
|
||||
* @brief Remove a column from a table
|
||||
**/
|
||||
function dropColumn($table_name, $column_name) {
|
||||
$query = sprintf("alter table %s%s drop column %s ", $this->prefix, $table_name, $column_name);
|
||||
|
|
@ -252,7 +252,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블의 column의 정보를 return
|
||||
* @brief Return column information of a table
|
||||
**/
|
||||
function isColumnExists($table_name, $column_name) {
|
||||
$query = sprintf("pragma table_info(%s%s)", $this->prefix, $table_name);
|
||||
|
|
@ -270,7 +270,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블에 특정 인덱스 추가
|
||||
* @brief Add an index to a table
|
||||
* $target_columns = array(col1, col2)
|
||||
* $is_unique? unique : none
|
||||
**/
|
||||
|
|
@ -285,7 +285,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블의 특정 인덱스 삭제
|
||||
* @brief Drop an index from a table
|
||||
**/
|
||||
function dropIndex($table_name, $index_name, $is_unique = false) {
|
||||
$key_name = sprintf('%s%s_%s', $this->prefix, $table_name, $index_name);
|
||||
|
|
@ -294,7 +294,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 테이블의 index 정보를 return
|
||||
* @brief Return index information of a table
|
||||
**/
|
||||
function isIndexExists($table_name, $index_name) {
|
||||
$key_name = sprintf('%s%s_%s', $this->prefix, $table_name, $index_name);
|
||||
|
|
@ -307,24 +307,24 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief xml 을 받아서 테이블을 생성
|
||||
* @brief create a table from xml file
|
||||
**/
|
||||
function createTableByXml($xml_doc) {
|
||||
return $this->_createTable($xml_doc);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief xml 을 받아서 테이블을 생성
|
||||
* @brief create a table from 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 to create a table using the schema xml
|
||||
*
|
||||
* type : number, varchar, text, char, date, \n
|
||||
* opt : notnull, default, size\n
|
||||
|
|
@ -334,8 +334,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;
|
||||
$table_name = $this->prefix.$table_name;
|
||||
|
|
@ -401,7 +400,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 조건문 작성하여 return
|
||||
* @brief Return conditional clause(where)
|
||||
**/
|
||||
function getCondition($output) {
|
||||
if(!$output->conditions) return;
|
||||
|
|
@ -445,15 +444,14 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief insertAct 처리
|
||||
* @brief 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'];
|
||||
|
|
@ -480,18 +478,16 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief updateAct 처리
|
||||
* @brief updateAct
|
||||
**/
|
||||
function _executeUpdateAct($output) {
|
||||
$table_count = count(array_values($output->tables));
|
||||
|
||||
// 대상 테이블이 1개일 경우
|
||||
// If a target table is one
|
||||
if($table_count == 1) {
|
||||
// 테이블 정리
|
||||
// list tables
|
||||
list($target_table) = array_values($output->tables);
|
||||
$target_table = $this->prefix.$target_table;
|
||||
|
||||
// 컬럼 정리
|
||||
// list columns
|
||||
foreach($output->columns as $key => $val) {
|
||||
if(!isset($val['value'])) continue;
|
||||
$name = $val['name'];
|
||||
|
|
@ -504,27 +500,23 @@
|
|||
$column_list[] = sprintf("%s = %s", $name, $value);
|
||||
}
|
||||
}
|
||||
|
||||
// 조건절 정리
|
||||
// List where cluase
|
||||
$condition = $this->getCondition($output);
|
||||
|
||||
$query = sprintf("update %s set %s %s", $target_table, implode(',',$column_list), $condition);
|
||||
|
||||
// 대상 테이블이 2개일 경우 (sqlite에서 update 테이블을 1개 이상 지정 못해서 이렇게 꽁수로... 다른 방법이 있으려나..)
|
||||
// If tables to update are morea than two (In sqlite, it is possible to update a single table only. Let me know if you know a better way)
|
||||
} elseif($table_count == 2) {
|
||||
// 테이블 정리
|
||||
// List tables
|
||||
foreach($output->tables as $key => $val) {
|
||||
$table_list[$val] = $this->prefix.$key;
|
||||
}
|
||||
list($source_table, $target_table) = array_values($table_list);
|
||||
|
||||
// 조건절 정리
|
||||
// List where cluase
|
||||
$condition = $this->getCondition($output);
|
||||
foreach($table_list as $key => $val) {
|
||||
$condition = eregi_replace($key.'\\.', $val.'.', $condition);
|
||||
}
|
||||
|
||||
// 컬럼 정리
|
||||
// List columns
|
||||
foreach($output->columns as $key => $val) {
|
||||
if(!isset($val['value'])) continue;
|
||||
$name = $val['name'];
|
||||
|
|
@ -547,15 +539,14 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief deleteAct 처리
|
||||
* @brief 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);
|
||||
|
|
@ -565,13 +556,13 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief selectAct 처리
|
||||
* @brief selectAct
|
||||
*
|
||||
* select의 경우 특정 페이지의 목록을 가져오는 것을 편하게 하기 위해\n
|
||||
* navigation이라는 method를 제공
|
||||
* To fetch a list of the page conveniently when selecting, \n
|
||||
* navigation method supported
|
||||
**/
|
||||
function _executeSelectAct($output) {
|
||||
// 테이블 정리
|
||||
// List tables
|
||||
$table_list = array();
|
||||
foreach($output->tables as $key => $val) {
|
||||
$table_list[] = $this->prefix.$val.' as '.$key;
|
||||
|
|
@ -616,8 +607,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 the condition to the query to use an index for ordering by list_order, update_order
|
||||
if($output->order) {
|
||||
$conditions = $this->getConditionList($output);
|
||||
if(!in_array('list_order', $conditions) && !in_array('update_order', $conditions)) {
|
||||
|
|
@ -655,7 +645,7 @@
|
|||
}
|
||||
|
||||
$query = sprintf("select %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('%s limit %d', $query, $output->list_count['value']);
|
||||
|
||||
$query .= (__DEBUG_QUERY__&1 && $output->query_id)?sprintf(' '.$this->comment_syntax,$this->query_id):'';
|
||||
|
|
@ -676,17 +666,17 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @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;
|
||||
/*
|
||||
// group by 절이 포함된 SELECT 쿼리의 전체 갯수를 구하기 위한 수정
|
||||
// 정상적인 동작이 확인되면 주석으로 막아둔 부분으로 대체합니다.
|
||||
// Modified to find total number of SELECT queries having group by clause
|
||||
// If it works correctly, uncomment the following codes
|
||||
//
|
||||
$count_condition = count($output->groups) ? sprintf('%s group by %s', $condition, implode(', ', $output->groups)) : $condition;
|
||||
$total_count = $this->getCountCache($output->tables, $count_condition);
|
||||
|
|
@ -700,8 +690,7 @@
|
|||
$this->putCountCache($output->tables, $count_condition, $total_count);
|
||||
}
|
||||
*/
|
||||
|
||||
// 전체 개수를 구함
|
||||
// Get a total count
|
||||
$count_query = sprintf("select count(*) as count from %s %s %s", implode(',',$table_list),implode(' ',$left_join), $condition);
|
||||
$count_query .= (__DEBUG_QUERY__&1 && $output->query_id)?sprintf(' '.$this->comment_syntax,$this->query_id . ' count(*)'):'';
|
||||
$this->_prepare($count_query);
|
||||
|
|
@ -714,16 +703,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
|
||||
if($output->order) {
|
||||
$conditions = $this->getConditionList($output);
|
||||
if(!in_array('list_order', $conditions) && !in_array('update_order', $conditions)) {
|
||||
|
|
@ -760,7 +746,7 @@
|
|||
$columns = join(',',$output->arg_columns);
|
||||
}
|
||||
|
||||
// return 결과물 생성
|
||||
// Return the result
|
||||
$buff = new Object();
|
||||
$buff->total_count = 0;
|
||||
$buff->total_page = 0;
|
||||
|
|
@ -768,7 +754,7 @@
|
|||
$buff->data = array();
|
||||
$buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count);
|
||||
|
||||
// 쿼리 실행
|
||||
// Query Execution
|
||||
$query = sprintf("select %s from %s %s %s %s", $columns, implode(',',$table_list),implode(' ',$left_join), $condition, $groupby_query.$orderby_query);
|
||||
$query = sprintf('%s limit %d, %d', $query, $start_count, $list_count);
|
||||
$query .= (__DEBUG_QUERY__&1 && $output->query_id)?sprintf(' '.$this->comment_syntax,$this->query_id):'';
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@
|
|||
|
||||
class DisplayHandler extends Handler {
|
||||
|
||||
var $content_size = 0; ///< 출력하는 컨텐츠의 사이즈
|
||||
var $content_size = 0; // /< The size of displaying contents
|
||||
|
||||
var $gz_enabled = false; ///< gzip 압축하여 컨텐츠 호출할 것인지에 대한 flag변수
|
||||
var $gz_enabled = false; // / <a flog variable whether to call contents after compressing by gzip
|
||||
var $handler = null;
|
||||
|
||||
/**
|
||||
|
|
@ -22,16 +22,14 @@
|
|||
* @param[in] $oModule the module object
|
||||
**/
|
||||
function printContent(&$oModule) {
|
||||
|
||||
// gzip encoding 지원 여부 체크
|
||||
// Check if the gzip encoding supported
|
||||
if(
|
||||
(defined('__OB_GZHANDLER_ENABLE__') && __OB_GZHANDLER_ENABLE__ == 1) &&
|
||||
strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')!==false &&
|
||||
function_exists('ob_gzhandler') &&
|
||||
extension_loaded('zlib')
|
||||
) $this->gz_enabled = true;
|
||||
|
||||
// request method에 따른 컨텐츠 결과물 추출
|
||||
// Extract contents to display by the request method
|
||||
if(Context::get('xeVirtualRequestMethod')=='xml') {
|
||||
require_once("./classes/display/VirtualXMLDisplayHandler.php");
|
||||
$handler = new VirtualXMLDisplayHandler();
|
||||
|
|
@ -51,33 +49,27 @@
|
|||
}
|
||||
|
||||
$output = $handler->toDoc($oModule);
|
||||
|
||||
// 출력하기 전에 trigger 호출 (before)
|
||||
// call a trigger before display
|
||||
ModuleHandler::triggerCall('display', 'before', $output);
|
||||
|
||||
// 애드온 실행
|
||||
// execute add-on
|
||||
$called_position = 'before_display_content';
|
||||
$oAddonController = &getController('addon');
|
||||
$addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone()?"mobile":"pc");
|
||||
@include($addon_file);
|
||||
|
||||
if(method_exists($handler, "prepareToPrint")) $handler->prepareToPrint($output);
|
||||
|
||||
// header 출력
|
||||
// header output
|
||||
if($this->gz_enabled) header("Content-Encoding: gzip");
|
||||
if(Context::getResponseMethod() == 'JSON') $this->_printJSONHeader();
|
||||
else if(Context::getResponseMethod() != 'HTML') $this->_printXMLHeader();
|
||||
else $this->_printHTMLHeader();
|
||||
|
||||
// debugOutput 출력
|
||||
// debugOutput output
|
||||
$this->content_size = strlen($output);
|
||||
$output .= $this->_debugOutput();
|
||||
|
||||
// 결과물 직접 출력
|
||||
// results directly output
|
||||
if($this->gz_enabled) print ob_gzhandler($output, 5);
|
||||
else print $output;
|
||||
|
||||
// 출력 후 trigger 호출 (after)
|
||||
// call a trigger after display
|
||||
ModuleHandler::triggerCall('display', 'after', $content);
|
||||
}
|
||||
|
||||
|
|
@ -91,8 +83,7 @@
|
|||
if(!__DEBUG__) return;
|
||||
|
||||
$end = getMicroTime();
|
||||
|
||||
// Firebug 콘솔 출력
|
||||
// Firebug console output
|
||||
if(__DEBUG_OUTPUT__ == 2 && version_compare(PHP_VERSION, '6.0.0') === -1) {
|
||||
static $firephp;
|
||||
if(!isset($firephp)) $firephp = FirePHP::getInstance(true);
|
||||
|
|
@ -101,8 +92,7 @@
|
|||
$firephp->fb('Change the value of __DEBUG_PROTECT_IP__ into your IP address in config/config.user.inc.php or config/config.inc.php', 'The IP address is not allowed.');
|
||||
return;
|
||||
}
|
||||
|
||||
// 전체 실행 시간 출력, Request/Response info 출력
|
||||
// display total execution time and Request/Response info
|
||||
if(__DEBUG__ & 2) {
|
||||
$firephp->fb(
|
||||
array('Request / Response info >>> '.$_SERVER['REQUEST_METHOD'].' / '.Context::getResponseMethod(),
|
||||
|
|
@ -135,8 +125,7 @@
|
|||
'TABLE'
|
||||
);
|
||||
}
|
||||
|
||||
// DB 쿼리 내역 출력
|
||||
// display DB query history
|
||||
if((__DEBUG__ & 4) && $GLOBALS['__db_queries__']) {
|
||||
$queries_output = array(array('Query', 'Elapsed time', 'Result'));
|
||||
foreach($GLOBALS['__db_queries__'] as $query) {
|
||||
|
|
@ -150,43 +139,34 @@
|
|||
'TABLE'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// 파일 및 HTML 주석으로 출력
|
||||
// dislpay the file and HTML comments
|
||||
} else {
|
||||
|
||||
// 전체 실행 시간 출력, Request/Response info 출력
|
||||
// display total execution time and Request/Response info
|
||||
if(__DEBUG__ & 2) {
|
||||
if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Request/Response 정보 작성
|
||||
// Request/Response information
|
||||
$buff .= "\n- Request/ Response info\n";
|
||||
$buff .= sprintf("\tRequest URI \t\t\t: %s:%s%s%s%s\n", $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING']?'?':'', $_SERVER['QUERY_STRING']);
|
||||
$buff .= sprintf("\tRequest method \t\t\t: %s\n", $_SERVER['REQUEST_METHOD']);
|
||||
$buff .= sprintf("\tResponse method \t\t: %s\n", Context::getResponseMethod());
|
||||
$buff .= sprintf("\tResponse contents size\t\t: %d byte\n", $this->content_size);
|
||||
|
||||
// 전체 실행 시간
|
||||
// total execution time
|
||||
$buff .= sprintf("\n- Total elapsed time : %0.5f sec\n", $end-__StartTime__);
|
||||
|
||||
$buff .= sprintf("\tclass file load elapsed time \t: %0.5f sec\n", $GLOBALS['__elapsed_class_load__']);
|
||||
$buff .= sprintf("\tTemplate compile elapsed time\t: %0.5f sec (%d called)\n", $GLOBALS['__template_elapsed__'], $GLOBALS['__TemplateHandlerCalled__']);
|
||||
$buff .= sprintf("\tXmlParse compile elapsed time\t: %0.5f sec\n", $GLOBALS['__xmlparse_elapsed__']);
|
||||
$buff .= sprintf("\tPHP elapsed time \t\t: %0.5f sec\n", $end-__StartTime__-$GLOBALS['__template_elapsed__']-$GLOBALS['__xmlparse_elapsed__']-$GLOBALS['__db_elapsed_time__']-$GLOBALS['__elapsed_class_load__']);
|
||||
|
||||
// 위젯 실행 시간 작성
|
||||
// widget execution time
|
||||
$buff .= sprintf("\n\tWidgets elapsed time \t\t: %0.5f sec", $GLOBALS['__widget_excute_elapsed__']);
|
||||
|
||||
// 레이아웃 실행 시간
|
||||
// layout execution time
|
||||
$buff .= sprintf("\n\tLayout compile elapsed time \t: %0.5f sec", $GLOBALS['__layout_compile_elapsed__']);
|
||||
|
||||
// 위젯, 에디터 컴포넌트 치환 시간
|
||||
// Widgets, the editor component replacement time
|
||||
$buff .= sprintf("\n\tTrans Content \t\t\t: %0.5f sec\n", $GLOBALS['__trans_content_elapsed__']);
|
||||
}
|
||||
|
||||
// DB 로그 작성
|
||||
// DB Logging
|
||||
if(__DEBUG__ & 4) {
|
||||
if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) {
|
||||
return;
|
||||
|
|
@ -206,8 +186,7 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// HTML 주석으로 출력
|
||||
// Output in HTML comments
|
||||
if($buff && __DEBUG_OUTPUT__ == 1 && Context::getResponseMethod() == 'HTML') {
|
||||
$buff = sprintf("[%s %s:%d]\n%s\n", date('Y-m-d H:i:s'), $file_name, $line_num, print_r($buff, true));
|
||||
|
||||
|
|
@ -217,8 +196,7 @@
|
|||
|
||||
return "<!--\r\n".$buff."\r\n-->";
|
||||
}
|
||||
|
||||
// 파일에 출력
|
||||
// Output to a file
|
||||
if($buff && __DEBUG_OUTPUT__ == 0) {
|
||||
$debug_file = _XE_PATH_.'files/_debug_message.php';
|
||||
$buff = sprintf("[%s %s:%d]\n%s\n", date('Y-m-d H:i:s'), $file_name, $line_num, print_r($buff, true));
|
||||
|
|
|
|||
|
|
@ -28,21 +28,21 @@ class HTMLDisplayHandler {
|
|||
|
||||
$edited_layout_file = $oModule->getEditedLayoutFile();
|
||||
|
||||
// 현재 요청된 레이아웃 정보를 구함
|
||||
// get the layout information currently requested
|
||||
$oLayoutModel = &getModel('layout');
|
||||
$layout_info = Context::get('layout_info');
|
||||
$layout_srl = $layout_info->layout_srl;
|
||||
|
||||
// 레이아웃과 연결되어 있으면 레이아웃 컴파일
|
||||
// compile if connected to the layout
|
||||
if($layout_srl > 0){
|
||||
|
||||
// faceoff 레이아웃일 경우 별도 처리
|
||||
// handle separately if the layout is faceoff
|
||||
if($layout_info && $layout_info->type == 'faceoff') {
|
||||
$oLayoutModel->doActivateFaceOff($layout_info);
|
||||
Context::set('layout_info', $layout_info);
|
||||
}
|
||||
|
||||
// 관리자 레이아웃 수정화면에서 변경된 CSS가 있는지 조사
|
||||
// search if the changes CSS exists in the admin layout edit window
|
||||
$edited_layout_css = $oLayoutModel->getUserLayoutCss($layout_srl);
|
||||
|
||||
if(file_exists($edited_layout_css)) Context::addCSSFile($edited_layout_css,true,'all','',100);
|
||||
|
|
@ -66,13 +66,13 @@ class HTMLDisplayHandler {
|
|||
|
||||
if(__DEBUG__==3) $start = getMicroTime();
|
||||
|
||||
// body 내의 <style ..></style>를 header로 이동
|
||||
// move <style ..></style> in body to the header
|
||||
$output = preg_replace_callback('!<style(.*?)<\/style>!is', array($this,'_moveStyleToHeader'), $output);
|
||||
|
||||
// 메타 파일 변경 (캐싱기능등으로 인해 위젯등에서 <!--Meta:경로--> 태그를 content에 넣는 경우가 있음
|
||||
$output = preg_replace_callback('/<!--(#)?Meta:([a-z0-9\_\/\.\@]+)-->/is', array($this,'_transMeta'), $output);
|
||||
// change a meta fine(widget often put the tag like <!--Meta:path--> to the content because of caching)
|
||||
$output = preg_replace_callback('/<!--Meta:([a-z0-9\_\/\.\@]+)-->/is', array($this,'_transMeta'), $output);
|
||||
|
||||
// rewrite module 사용시 생기는 상대경로에 대한 처리를 함
|
||||
// handles a relative path generated by using the rewrite module
|
||||
if(Context::isAllowRewrite()) {
|
||||
$url = parse_url(Context::getRequestUri());
|
||||
$real_path = $url['path'];
|
||||
|
|
@ -89,15 +89,15 @@ class HTMLDisplayHandler {
|
|||
}
|
||||
}
|
||||
|
||||
// 간혹 background-image에 url(none) 때문에 request가 한번 더 일어나는 경우가 생기는 것을 방지
|
||||
// prevent the 2nd request due to url(none) of the background-image
|
||||
$output = preg_replace('/url\((["\']?)none(["\']?)\)/is', 'none', $output);
|
||||
|
||||
if(__DEBUG__==3) $GLOBALS['__trans_content_elapsed__'] = getMicroTime()-$start;
|
||||
|
||||
// 불필요한 정보 제거
|
||||
// Remove unnecessary information
|
||||
$output = preg_replace('/member\_\-([0-9]+)/s','member_0',$output);
|
||||
|
||||
// 최종 레이아웃 변환
|
||||
// convert the final layout
|
||||
Context::set('content', $output);
|
||||
$oTemplate = &TemplateHandler::getInstance();
|
||||
if(Mobile::isFromMobilePhone()) {
|
||||
|
|
@ -109,7 +109,7 @@ class HTMLDisplayHandler {
|
|||
$output = $oTemplate->compile('./common/tpl', 'common_layout');
|
||||
}
|
||||
|
||||
// 사용자 정의 언어 변환
|
||||
// replace the user-defined-language
|
||||
$oModuleController = &getController('module');
|
||||
$oModuleController->replaceDefinedLangCode($output);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,15 +2,15 @@
|
|||
/**
|
||||
* @class EditorHandler
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief edit component의 상위 클래스임
|
||||
* @brief superclass of the edit component
|
||||
*
|
||||
* 주로 하는 일은 컴포넌트 요청시 컴포넌트에서 필요로 하는 변수를 세팅해준다
|
||||
* set up the component variables
|
||||
**/
|
||||
|
||||
class EditorHandler extends Object {
|
||||
|
||||
/**
|
||||
* @brief 컴포넌트의 xml및 관련 정보들을 설정
|
||||
* @brief set the xml and other information of the component
|
||||
**/
|
||||
function setInfo($info) {
|
||||
Context::set('component_info', $info);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* @class ExtraVar
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief 게시글, 회원등에서 사용하는 확장변수를 핸들링하는 클래스
|
||||
* @brief a class to handle extra variables used in posts, member and others
|
||||
*
|
||||
**/
|
||||
class ExtraVar {
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 확장변수 키를 등록
|
||||
* @brief register a key of extra variable
|
||||
* @param module_srl, idx, name, type, default, desc, is_required, search, value
|
||||
**/
|
||||
function setExtraVarKeys($extra_keys) {
|
||||
|
|
@ -38,7 +38,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 확장변수 객체 배열 return
|
||||
* @brief Return an array of extra vars
|
||||
**/
|
||||
function getExtraVars() {
|
||||
return $this->keys;
|
||||
|
|
@ -48,7 +48,7 @@
|
|||
/**
|
||||
* @class ExtraItem
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief 확장변수의 개별 값
|
||||
* @brief each value of the extra vars
|
||||
**/
|
||||
class ExtraItem {
|
||||
var $module_srl = 0;
|
||||
|
|
@ -80,14 +80,14 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 값 지정
|
||||
* @brief Values
|
||||
**/
|
||||
function setValue($value) {
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief type에 따라서 주어진 값을 변형하여 원형 값을 return
|
||||
* @brief return a given value converted based on its type
|
||||
**/
|
||||
function _getTypeValue($type, $value) {
|
||||
$value = trim($value);
|
||||
|
|
@ -134,8 +134,8 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 값을 return
|
||||
* 원형 값을 HTML 결과물로 return
|
||||
* @brief Return value
|
||||
* return the original values for HTML result
|
||||
**/
|
||||
function getValueHTML() {
|
||||
$value = $this->_getTypeValue($this->type, $this->value);
|
||||
|
|
@ -174,7 +174,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief type에 따른 form을 리턴
|
||||
* @brief return a form based on its type
|
||||
**/
|
||||
function getFormHTML() {
|
||||
static $id_num = 1000;
|
||||
|
|
@ -188,17 +188,15 @@
|
|||
|
||||
$buff = '';
|
||||
switch($type) {
|
||||
// 홈페이지 주소
|
||||
// Homepage
|
||||
case 'homepage' :
|
||||
$buff .= '<input type="text" name="'.$column_name.'" value="'.$value.'" class="homepage" />';
|
||||
break;
|
||||
|
||||
// Email 주소
|
||||
// Email Address
|
||||
case 'email_address' :
|
||||
$buff .= '<input type="text" name="'.$column_name.'" value="'.$value.'" class="email_address" />';
|
||||
break;
|
||||
|
||||
// 전화번호
|
||||
// Phone Number
|
||||
case 'tel' :
|
||||
$buff .=
|
||||
'<input type="text" name="'.$column_name.'" value="'.$value[0].'" size="4" class="tel" />'.
|
||||
|
|
@ -210,8 +208,7 @@
|
|||
case 'textarea' :
|
||||
$buff .= '<textarea name="'.$column_name.'" class="textarea">'.$value.'</textarea>';
|
||||
break;
|
||||
|
||||
// 다중 선택
|
||||
// multiple choice
|
||||
case 'checkbox' :
|
||||
$buff .= '<ul>';
|
||||
foreach($default as $v) {
|
||||
|
|
@ -225,8 +222,7 @@
|
|||
}
|
||||
$buff .= '</ul>';
|
||||
break;
|
||||
|
||||
// 단일 선택
|
||||
// single choice
|
||||
case 'select' :
|
||||
$buff .= '<select name="'.$column_name.'" class="select">';
|
||||
foreach($default as $v) {
|
||||
|
|
@ -251,8 +247,7 @@
|
|||
}
|
||||
$buff .= '</ul>';
|
||||
break;
|
||||
|
||||
// 날짜 입력
|
||||
// date
|
||||
case 'date' :
|
||||
// datepicker javascript plugin load
|
||||
Context::loadJavascriptPlugin('ui.datepicker');
|
||||
|
|
@ -272,8 +267,7 @@
|
|||
'})(jQuery);'."\n".
|
||||
'</script>';
|
||||
break;
|
||||
|
||||
// 주소 입력
|
||||
// address
|
||||
case "kr_zip" :
|
||||
// krzip address javascript plugin load
|
||||
Context::loadJavascriptPlugin('ui.krzip');
|
||||
|
|
@ -298,8 +292,7 @@
|
|||
'<input type="text" name="'.$column_name.'" value="'.htmlspecialchars($value[1]).'" class="address" />'.
|
||||
'';
|
||||
break;
|
||||
|
||||
// 일반 text
|
||||
// General text
|
||||
default :
|
||||
$buff .=' <input type="text" name="'.$column_name.'" value="'.$value.'" class="text" />';
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -30,8 +30,7 @@
|
|||
$source_dir = FileHandler::getRealPath($source_dir);
|
||||
$target_dir = FileHandler::getRealPath($target_dir);
|
||||
if(!is_dir($source_dir)) return false;
|
||||
|
||||
// target이 없을땐 생성
|
||||
// generate when no target exists
|
||||
if(!file_exists($target_dir)) FileHandler::makeDir($target_dir);
|
||||
|
||||
if(substr($source_dir, -1) != '/') $source_dir .= '/';
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief 메일 발송
|
||||
* @brief Mailing
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
**/
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@
|
|||
/**
|
||||
* @brief sett to set the template path for refresh.html
|
||||
* @remark refresh.html is executed as a result of method execution
|
||||
* 공통 tpl중 refresh.html을 실행할 뿐..
|
||||
* Tpl as the common run of the refresh.html ..
|
||||
**/
|
||||
function setRefreshPage() {
|
||||
$this->setTemplatePath('./common/tpl');
|
||||
|
|
@ -76,21 +76,18 @@
|
|||
* @param[in] $xml_info object containing module description
|
||||
**/
|
||||
function setModuleInfo($module_info, $xml_info) {
|
||||
// 기본 변수 설정
|
||||
// The default variable settings
|
||||
$this->mid = $module_info->mid;
|
||||
$this->module_srl = $module_info->module_srl;
|
||||
$this->module_info = $module_info;
|
||||
$this->xml_info = $xml_info;
|
||||
$this->skin_vars = $module_info->skin_vars;
|
||||
|
||||
// 웹서비스에서 꼭 필요한 인증 정보와 권한 설정 체크
|
||||
// validate certificate info and permission settings necessary in Web-services
|
||||
$is_logged = Context::get('is_logged');
|
||||
$logged_info = Context::get('logged_info');
|
||||
|
||||
// module model 객체 생성
|
||||
// module model create an object
|
||||
$oModuleModel = &getModel('module');
|
||||
|
||||
// XE에서 access, manager (== is_admin) 는 고정된 권한명이며 이와 관련된 권한 설정
|
||||
// permission settings. access, manager(== is_admin) are fixed and privilege name in XE
|
||||
$module_srl = Context::get('module_srl');
|
||||
if(!$module_info->mid && preg_match('/^([0-9]+)$/',$module_srl)) {
|
||||
$request_module = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
|
||||
|
|
@ -100,19 +97,15 @@
|
|||
} else {
|
||||
$grant = $oModuleModel->getGrant($module_info, $logged_info, $xml_info);
|
||||
}
|
||||
|
||||
// 현재 모듈의 access 권한이 없으면 권한 없음 표시
|
||||
// display no permission if the current module doesn't have an access privilege
|
||||
//if(!$grant->access) return $this->stop("msg_not_permitted");
|
||||
|
||||
// 관리 권한이 없으면 permision, action 확인
|
||||
// checks permission and action if you don't have an admin privilege
|
||||
if(!$grant->manager) {
|
||||
// 현재 요청된 action의 퍼미션 type(guest, member, manager, root)를 구함
|
||||
// get permission types(guest, member, manager, root) of the currently requested action
|
||||
$permission_target = $xml_info->permission->{$this->act};
|
||||
|
||||
// module.xml에 명시된 퍼미션이 없을때 action명에 Admin이 있으면 manager로 체크
|
||||
// check manager if a permission in module.xml otherwise action if no permission
|
||||
if(!$permission_target && substr_count($this->act, 'Admin')) $permission_target = 'manager';
|
||||
|
||||
// 권한 체크
|
||||
// Check permissions
|
||||
switch($permission_target) {
|
||||
case 'root' :
|
||||
$this->stop('msg_not_permitted_act');
|
||||
|
|
@ -125,8 +118,7 @@
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 권한변수 설정
|
||||
// permission variable settings
|
||||
$this->grant = $grant;
|
||||
Context::set('grant', $grant);
|
||||
|
||||
|
|
@ -138,14 +130,12 @@
|
|||
* @param $msg_code an error code
|
||||
**/
|
||||
function stop($msg_code) {
|
||||
// proc 수행을 중지 시키기 위한 플래그 세팅
|
||||
// flag setting to stop the proc processing
|
||||
$this->stop_proc = true;
|
||||
|
||||
// 에러 처리
|
||||
// Error handling
|
||||
$this->setError(-1);
|
||||
$this->setMessage($msg_code);
|
||||
|
||||
// message 모듈의 에러 표시
|
||||
// Error message display by message module
|
||||
$type = Mobile::isFromMobilePhone() ? 'mobile' : 'view';
|
||||
$oMessageObject = &ModuleHandler::getModuleInstance('message',$type);
|
||||
$oMessageObject->setError(-1);
|
||||
|
|
@ -241,7 +231,7 @@
|
|||
*
|
||||
**/
|
||||
function proc() {
|
||||
// stop_proc==true이면 그냥 패스
|
||||
// pass if stop_proc is true
|
||||
if($this->stop_proc) return false;
|
||||
|
||||
// trigger call
|
||||
|
|
@ -252,23 +242,20 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
// addon 실행(called_position 를 before_module_proc로 하여 호출)
|
||||
// execute an addon(call called_position as before_module_proc)
|
||||
$called_position = 'before_module_proc';
|
||||
$oAddonController = &getController('addon');
|
||||
$addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone()?"mobile":"pc");
|
||||
@include($addon_file);
|
||||
|
||||
if(isset($this->xml_info->action->{$this->act}) && method_exists($this, $this->act)) {
|
||||
|
||||
// 권한 체크
|
||||
// Check permissions
|
||||
if(!$this->grant->access) return $this->stop("msg_not_permitted_act");
|
||||
|
||||
// 모듈의 스킨 정보를 연동 (스킨 정보의 테이블 분리로 동작대상 모듈에만 스킨 정보를 싱크시키도록 변경)
|
||||
// integrate skin information of the module(change to sync skin info with the target module only by seperating its table)
|
||||
$oModuleModel = &getModel('module');
|
||||
$oModuleModel->syncSkinInfoToModuleInfo($this->module_info);
|
||||
Context::set('module_info', $this->module_info);
|
||||
|
||||
// 실행
|
||||
// Run
|
||||
$output = $this->{$this->act}();
|
||||
}
|
||||
else {
|
||||
|
|
@ -283,7 +270,7 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
// addon 실행(called_position 를 after_module_proc로 하여 호출)
|
||||
// execute an addon(call called_position as after_module_proc)
|
||||
$called_position = 'after_module_proc';
|
||||
$oAddonController = &getController('addon');
|
||||
$addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone()?"mobile":"pc");
|
||||
|
|
@ -294,8 +281,7 @@
|
|||
$this->setMessage($output->getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
// view action이고 결과 출력이 XMLRPC 또는 JSON일 경우 해당 모듈의 api method를 실행
|
||||
// execute api methos of the module if view action is and result is XMLRPC or JSON
|
||||
if($this->module_info->module_type == 'view'){
|
||||
if(Context::getResponseMethod() == 'XMLRPC' || Context::getResponseMethod() == 'JSON') {
|
||||
$oAPI = getAPI($this->module_info->module, 'api');
|
||||
|
|
@ -304,7 +290,6 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@
|
|||
|
||||
class Object {
|
||||
|
||||
var $error = 0; ///< 에러 코드 (0이면 에러 아님)
|
||||
var $message = 'success'; ///< 에러 메세지 (success이면 에러 아님)
|
||||
var $error = 0; // / "Error code (if 0, it is not an error)
|
||||
var $message = 'success'; // / "Error message (if success, it is not an error)
|
||||
|
||||
var $variables = array(); ///< 추가 변수
|
||||
var $variables = array(); // /< an additional variable
|
||||
|
||||
/**
|
||||
* @brief constructor
|
||||
|
|
|
|||
|
|
@ -151,22 +151,22 @@
|
|||
// replace value of src in img/input/script tag
|
||||
$buff = preg_replace_callback('/<(img|input|script)([^>]*)src="([^"]*?)"/is', array($this, '_replacePath'), $buff);
|
||||
|
||||
// loop 템플릿 문법을 변환
|
||||
// replace the loop template syntax
|
||||
$buff = $this->_replaceLoop($buff);
|
||||
|
||||
// cond 템플릿 문법을 변환
|
||||
// |replace the cond template syntax
|
||||
$buff = $this->_replaceCond($buff);
|
||||
|
||||
// |cond 템플릿 문법을 변환
|
||||
// replace the cond template syntax
|
||||
$buff = preg_replace_callback("/<\/?(\w+)((\s+\w+(\s*=\s*(?:\".*?\"|'.*?'|[^'\">\s]+))?)+\s*|\s*)\/?>/i", array($this, '_replacePipeCond'), $buff);
|
||||
|
||||
// include 태그의 변환
|
||||
// replace the include tags
|
||||
$buff = preg_replace_callback('!<include ([^>]+)>!is', array($this, '_replaceInclude'), $buff);
|
||||
|
||||
// unload/ load 태그의 변환
|
||||
// replace unload/load tags
|
||||
$buff = preg_replace_callback('!<(unload|load) ([^>]+)>!is', array($this, '_replaceLoad'), $buff);
|
||||
|
||||
// 가상 태그인 block의 변환
|
||||
// replace block which is a virtual tag
|
||||
$buff = preg_replace('/<block([ ]*)>|<\/block>/is','',$buff);
|
||||
|
||||
// replace include <!--#include($filename)-->
|
||||
|
|
@ -190,7 +190,7 @@
|
|||
// replace variables
|
||||
$buff = preg_replace_callback('/\{[^@^ ]([^\{\}\n]+)\}/i', array($this, '_compileVarToContext'), $buff);
|
||||
|
||||
// PHP 변수형의 변환 ($문자등을 공유 context로 변환)
|
||||
// replace PHP variable types(converts characters like $ into shared context)
|
||||
$buff = $this->_replaceVarInPHP($buff);
|
||||
|
||||
// replace parts not displaying results
|
||||
|
|
@ -246,7 +246,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief loop 문법의 변환
|
||||
* @brief replace loop syntax
|
||||
**/
|
||||
function _replaceLoop($buff)
|
||||
{
|
||||
|
|
@ -331,7 +331,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief pipe cond, |cond= 의 변환
|
||||
* @brief replace pipe cond and |cond=
|
||||
**/
|
||||
function _replacePipeCond($matches)
|
||||
{
|
||||
|
|
@ -346,7 +346,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief cond 문법의 변환
|
||||
* @brief replace cond syntax
|
||||
**/
|
||||
function _replaceCond($buff)
|
||||
{
|
||||
|
|
@ -406,7 +406,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 다른 template파일을 include하는 include tag의 변환
|
||||
* @brief replace include tags which include other template files
|
||||
**/
|
||||
function _replaceInclude($matches)
|
||||
{
|
||||
|
|
@ -442,7 +442,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief load 태그의 변환
|
||||
* @brief replace load tags
|
||||
**/
|
||||
function _replaceLoad($matches) {
|
||||
$output = $matches[0];
|
||||
|
|
@ -539,7 +539,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief $문자 의 PHP 변수 변환
|
||||
* @brief replace PHP variables of $ character
|
||||
**/
|
||||
function _replaceVarInPHP($buff) {
|
||||
$head = $tail = '';
|
||||
|
|
@ -558,7 +558,7 @@
|
|||
|
||||
|
||||
/**
|
||||
* @brief php5의 class::$변수명의 경우 context를 사용하지 않아야 하기에 함수로 대체
|
||||
* @brief if class::$variable_name in php5, replace the function not to use context
|
||||
**/
|
||||
function _replaceVarString($matches)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,11 +12,11 @@
|
|||
* <form> <-- code to validate data in the form
|
||||
* <node target="name" required="true" minlength="1" maxlength="5" filter="email,userid,alpha,number" equalto="target" />
|
||||
* </form>
|
||||
* <parameter> <-- 폼 항목을 조합하여 key=val 의 js array로 return, act는 필수
|
||||
* <parameter> "- A form of key = val combination of items to js array return, act required
|
||||
* <param name="key" target="target" />
|
||||
* </parameter>
|
||||
* <response callback_func="callback 받게 될 js function 이름 지정" > <-- 서버에 ajax로 전송하여 받을 결과값
|
||||
* <tag name="error" /> <-- error이름의 결과값을 받겠다는 것
|
||||
* <response callback_func="specifying the name of js function to callback" > "- Result to get by sending ajax to the server
|
||||
* <tag name="error" /> <- get the result of error name
|
||||
* </response>
|
||||
* </filter>
|
||||
* }
|
||||
|
|
@ -36,7 +36,7 @@
|
|||
*
|
||||
* - parameter - param
|
||||
* name = key : indicate that a new array, 'key' will be created and a value will be assigned to it
|
||||
* target = target_name : target form element의 값을 가져옴
|
||||
* target = target_name: get the value of the target form element
|
||||
*
|
||||
* - response
|
||||
* tag = key : name of variable that will contain the result of the execution
|
||||
|
|
@ -45,9 +45,9 @@
|
|||
|
||||
class XmlJsFilter extends XmlParser {
|
||||
var $version = '0.2.5';
|
||||
var $compiled_path = './files/cache/js_filter_compiled/'; ///< 컴파일된 캐시 파일이 놓일 위치
|
||||
var $xml_file = NULL; ///< 대상 xml 파일
|
||||
var $js_file = NULL; ///< 컴파일된 js 파일
|
||||
var $compiled_path = './files/cache/js_filter_compiled/'; // / directory path for compiled cache file
|
||||
var $xml_file = NULL; // / Target xml file
|
||||
var $js_file = NULL; // / Compiled js file
|
||||
|
||||
/**
|
||||
* @brief constructor
|
||||
|
|
@ -75,7 +75,7 @@
|
|||
function _compile() {
|
||||
global $lang;
|
||||
|
||||
// xml 파일을 읽음
|
||||
// read xml file
|
||||
$buff = FileHandler::readFile($this->xml_file);
|
||||
|
||||
// xml parsing
|
||||
|
|
@ -84,7 +84,7 @@
|
|||
$attrs = $xml_obj->filter->attrs;
|
||||
$rules = $xml_obj->filter->rules;
|
||||
|
||||
// XmlJsFilter는 filter_name, field, parameter 3개의 데이터를 핸들링
|
||||
// XmlJsFilter handles three data; filter_name, field, and parameter
|
||||
$filter_name = $attrs->name;
|
||||
$confirm_msg_code = $attrs->confirm_msg_code;
|
||||
$module = $attrs->module;
|
||||
|
|
@ -101,27 +101,27 @@
|
|||
$response_tag = $xml_obj->filter->response->tag;
|
||||
if($response_tag && !is_array($response_tag)) $response_tag = array($response_tag);
|
||||
|
||||
// extend_filter가 있을 경우 해당 method를 호출하여 결과를 받음
|
||||
// If extend_filter exists, result returned by calling the method
|
||||
if($extend_filter) {
|
||||
|
||||
// extend_filter가 있을 경우 캐시 사용을 못하도록 js 캐시 파일명을 변경
|
||||
// If extend_filter exists, it changes the name of cache not to use cache
|
||||
$this->js_file .= '.nocache.js';
|
||||
|
||||
// extend_filter는 module.method 로 지칭되어 이를 분리
|
||||
// Separate the extend_filter
|
||||
list($module_name, $method) = explode('.',$extend_filter);
|
||||
|
||||
// 모듈 이름과 method가 있을 경우 진행
|
||||
// contibue if both module_name and methos exist.
|
||||
if($module_name&&$method) {
|
||||
// 해당 module의 model 객체를 받음
|
||||
// get model object of the module
|
||||
$oExtendFilter = &getModel($module_name);
|
||||
|
||||
// method가 존재하면 실행
|
||||
// execute if method exists
|
||||
if(method_exists($oExtendFilter, $method)) {
|
||||
// 결과를 받음
|
||||
// get the result
|
||||
$extend_filter_list = $oExtendFilter->{$method}(true);
|
||||
$extend_filter_count = count($extend_filter_list);
|
||||
|
||||
// 결과에서 lang값을 이용 문서 변수에 적용
|
||||
// apply lang_value from the result to the variable
|
||||
for($i=0; $i < $extend_filter_count; $i++) {
|
||||
$name = $extend_filter_list[$i]->name;
|
||||
$lang_value = $extend_filter_list[$i]->lang;
|
||||
|
|
@ -132,7 +132,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
// 언어 입력을 위한 사용되는 필드 조사
|
||||
// search the field to be used for entering language
|
||||
$target_list = array();
|
||||
$target_type_list = array();
|
||||
|
||||
|
|
@ -152,7 +152,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
// field, 즉 체크항목의 script 생성
|
||||
// generates a field, which is a script of the checked item
|
||||
$node_count = count($field_node);
|
||||
if($node_count) {
|
||||
foreach($field_node as $key =>$node) {
|
||||
|
|
@ -179,7 +179,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
// extend_filter_item 체크
|
||||
// Check extend_filter_item
|
||||
$rule_types = array('homepage'=>'homepage', 'email_address'=>'email');
|
||||
|
||||
for($i=0;$i<$extend_filter_count;$i++) {
|
||||
|
|
@ -188,7 +188,7 @@
|
|||
|
||||
if(!$target) continue;
|
||||
|
||||
// extend filter item의 type으로 rule을 구함
|
||||
// get the filter from the type of extend filter item
|
||||
$type = $filter_item->type;
|
||||
$rule = $rule_types[$type]?$rule_types[$type]:'';
|
||||
$required = ($filter_item->required == 'true');
|
||||
|
|
@ -202,11 +202,11 @@
|
|||
if(!$target_type_list[$target]) $target_type_list[$target] = $type;
|
||||
}
|
||||
|
||||
// 데이터를 만들기 위한 parameter script 생성
|
||||
// generates parameter script to create dbata
|
||||
$rename_params = array();
|
||||
$parameter_count = count($parameter_param);
|
||||
if($parameter_count) {
|
||||
// 기본 필터 내용의 parameter로 구성
|
||||
// contains parameter of the default filter contents
|
||||
foreach($parameter_param as $key =>$param) {
|
||||
$attrs = $param->attrs;
|
||||
$name = trim($attrs->name);
|
||||
|
|
@ -217,7 +217,7 @@
|
|||
if($name && !in_array($name, $target_list)) $target_list[] = $name;
|
||||
}
|
||||
|
||||
// extend_filter_item 체크
|
||||
// Check extend_filter_item
|
||||
for($i=0;$i<$extend_filter_count;$i++) {
|
||||
$filter_item = $extend_filter_list[$i];
|
||||
$target = $name = trim($filter_item->name);
|
||||
|
|
@ -227,7 +227,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
// response script 생성
|
||||
// generates the response script
|
||||
$response_count = count($response_tag);
|
||||
$responses = array();
|
||||
for($i=0;$i<$response_count;$i++) {
|
||||
|
|
@ -236,7 +236,7 @@
|
|||
$responses[] = "'{$name}'";
|
||||
}
|
||||
|
||||
// lang : form field description
|
||||
// writes lang values of the form field
|
||||
$target_count = count($target_list);
|
||||
for($i=0;$i<$target_count;$i++) {
|
||||
$target = $target_list[$i];
|
||||
|
|
@ -244,7 +244,7 @@
|
|||
$js_messages[] = sprintf("v.cast('ADD_MESSAGE',['%s','%s']);", $target, addslashes($lang->{$target}));
|
||||
}
|
||||
|
||||
// target type을 기록
|
||||
// writes the target type
|
||||
/*
|
||||
$target_type_count = count($target_type_list);
|
||||
if($target_type_count) {
|
||||
|
|
@ -254,7 +254,7 @@
|
|||
}
|
||||
*/
|
||||
|
||||
// lang : error message
|
||||
// writes error messages
|
||||
foreach($lang->filter as $key => $val) {
|
||||
if(!$val) $val = $key;
|
||||
$js_messages[] = sprintf("v.cast('ADD_MESSAGE',['%s','%s']);", $key, $val);
|
||||
|
|
@ -276,7 +276,7 @@
|
|||
$jsdoc[] = '})(jQuery);';
|
||||
$jsdoc = implode("\n", $jsdoc);
|
||||
|
||||
// js파일 생성
|
||||
// generates the js file
|
||||
FileHandler::writeFile($this->js_file, $jsdoc);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,10 +19,10 @@
|
|||
var $input = NULL; ///< input xml
|
||||
var $output = array(); ///< output object
|
||||
|
||||
var $lang = "en"; ///< 기본 언어타입
|
||||
var $lang = "en"; // /< The default language type
|
||||
|
||||
/**
|
||||
* @brief load a xml file specified by a filename and parse it to return the resultant data object
|
||||
* @brief load a xml file specified by a filename and parse it to Return the resultant data object
|
||||
* @param[in] $filename a file path of file
|
||||
* @return Returns a data object containing data extracted from a xml file or NULL if a specified file does not exist
|
||||
**/
|
||||
|
|
@ -40,7 +40,7 @@
|
|||
* @return Returns a resultant data object or NULL in case of error
|
||||
**/
|
||||
function parse($input = '') {
|
||||
// 디버그를 위한 컴파일 시작 시간 저장
|
||||
// Save the compile starting time for debugging
|
||||
if(__DEBUG__==3) $start = getMicroTime();
|
||||
|
||||
$this->lang = Context::getLangType();
|
||||
|
|
@ -48,12 +48,12 @@
|
|||
$this->input = $input?$input:$GLOBALS['HTTP_RAW_POST_DATA'];
|
||||
$this->input = str_replace(array('',''),array('',''),$this->input);
|
||||
|
||||
// 지원언어 종류를 뽑음
|
||||
// extracts a supported language
|
||||
preg_match_all("/xml:lang=\"([^\"].+)\"/i", $this->input, $matches);
|
||||
|
||||
// xml:lang이 쓰였을 경우 지원하는 언어종류를 뽑음
|
||||
// extracts the supported lanuage when xml:lang is used
|
||||
if(count($matches[1]) && $supported_lang = array_unique($matches[1])) {
|
||||
// supported_lang에 현재 접속자의 lang이 없으면 en이 있는지 확인하여 en이 있으면 en을 기본, 아니면 첫번째것을..
|
||||
// if lang of the first log-in user doesn't exist, apply en by default if exists. Otherwise apply the first lang.
|
||||
if(!in_array($this->lang, $supported_lang)) {
|
||||
if(in_array('en', $supported_lang)) {
|
||||
$this->lang = 'en';
|
||||
|
|
@ -61,7 +61,7 @@
|
|||
$this->lang = array_shift($supported_lang);
|
||||
}
|
||||
}
|
||||
// 특별한 언어가 지정되지 않았다면 언어체크를 하지 않음
|
||||
// uncheck the language if no specific language is set.
|
||||
} else {
|
||||
unset($this->lang);
|
||||
}
|
||||
|
|
@ -78,8 +78,7 @@
|
|||
if(!count($this->output)) return;
|
||||
|
||||
$output = array_shift($this->output);
|
||||
|
||||
// 디버그를 위한 컴파일 시작 시간 저장
|
||||
// Save compile starting time for debugging
|
||||
if(__DEBUG__==3) $GLOBALS['__xmlparse_elapsed__'] += getMicroTime() - $start;
|
||||
|
||||
return $output;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
* @remarks {there should be a way to report an error}
|
||||
**/
|
||||
function parse($query_id, $xml_file, $cache_file) {
|
||||
// query xml 파일을 찾아서 파싱, 결과가 없으면 return
|
||||
// parse the query xml file. Return if get no result
|
||||
$buff = FileHandler::readFile($xml_file);
|
||||
$xml_obj = parent::parse($buff);
|
||||
if(!$xml_obj) return;
|
||||
|
|
@ -40,12 +40,10 @@
|
|||
$module = $id_args[1];
|
||||
$id = $id_args[2];
|
||||
}
|
||||
|
||||
// insert, update, delete, select등의 action
|
||||
// actions like insert, update, delete, select and so on
|
||||
$action = strtolower($xml_obj->query->attrs->action);
|
||||
if(!$action) return;
|
||||
|
||||
// 테이블 정리 (배열코드로 변환)
|
||||
// get the table list(converting an array code)
|
||||
$tables = $xml_obj->query->tables->table;
|
||||
$output->left_tables = array();
|
||||
|
||||
|
|
@ -54,8 +52,7 @@
|
|||
if(!$tables) return;
|
||||
if(!is_array($tables)) $tables = array($tables);
|
||||
foreach($tables as $key => $val) {
|
||||
|
||||
// 테이블과 alias의 이름을 구함
|
||||
// get the name of tables and aliases
|
||||
$table_name = $val->attrs->name;
|
||||
$alias = $val->attrs->alias;
|
||||
if(!$alias) $alias = $table_name;
|
||||
|
|
@ -66,8 +63,7 @@
|
|||
$output->left_tables[$alias] = $val->attrs->type;
|
||||
$left_conditions[$alias] = $val->conditions;
|
||||
}
|
||||
|
||||
// 테이블을 찾아서 컬럼의 속성을 구함
|
||||
// get column properties from the table
|
||||
$table_file = sprintf('%s%s/%s/schemas/%s.xml', _XE_PATH_, 'modules', $module, $table_name);
|
||||
if(!file_exists($table_file)) {
|
||||
$searched_list = FileHandler::readDir(_XE_PATH_.'modules');
|
||||
|
|
@ -93,9 +89,7 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 컬럼 정리
|
||||
// Column list
|
||||
$columns = $xml_obj->query->columns->column;
|
||||
$out = $this->_setColumn($columns);
|
||||
$output->columns = $out->columns;
|
||||
|
|
@ -114,8 +108,7 @@
|
|||
$group_list = $xml_obj->query->groups->group;
|
||||
$out = $this->_setGroup($group_list);
|
||||
$output->groups = $out->groups;
|
||||
|
||||
// 네비게이션 정리
|
||||
// Navigation
|
||||
$out = $this->_setNavigation($xml_obj);
|
||||
$output->order = $out->order;
|
||||
$output->list_count = $out->list_count;
|
||||
|
|
@ -132,8 +125,7 @@
|
|||
}
|
||||
}
|
||||
$buff .= ' );'."\n";
|
||||
|
||||
// php script 생성
|
||||
// generates a php script
|
||||
$buff .= '$output->_tables = array( ';
|
||||
foreach($output->tables as $key => $val) {
|
||||
$buff .= sprintf('"%s"=>"%s",', $key, $val);
|
||||
|
|
@ -147,22 +139,19 @@
|
|||
}
|
||||
$buff .= ' );'."\n";
|
||||
}
|
||||
|
||||
// column 정리
|
||||
// column info
|
||||
if($column_count) {
|
||||
$buff .= '$output->columns = array ( ';
|
||||
$buff .= $this->_getColumn($output->columns);
|
||||
$buff .= ' );'."\n";
|
||||
}
|
||||
|
||||
// conditions 정리
|
||||
// get conditions
|
||||
if($condition_count) {
|
||||
$buff .= '$output->conditions = array ( ';
|
||||
$buff .= $this->_getConditions($output->conditions);
|
||||
$buff .= ' );'."\n";
|
||||
}
|
||||
|
||||
// conditions 정리
|
||||
// get conditions
|
||||
if(count($output->left_conditions)) {
|
||||
$buff .= '$output->left_conditions = array ( ';
|
||||
foreach($output->left_conditions as $key => $val){
|
||||
|
|
@ -173,7 +162,7 @@
|
|||
$buff .= ' );'."\n";
|
||||
}
|
||||
|
||||
// args 변수 확인
|
||||
// get arguments
|
||||
$arg_list = $this->getArguments();
|
||||
if($arg_list)
|
||||
{
|
||||
|
|
@ -184,7 +173,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
// order 정리
|
||||
// order
|
||||
if($output->order) {
|
||||
$buff .= '$output->order = array(';
|
||||
foreach($output->order as $key => $val) {
|
||||
|
|
@ -193,22 +182,22 @@
|
|||
$buff .= ');'."\n";
|
||||
}
|
||||
|
||||
// list_count 정리
|
||||
// list_count
|
||||
if($output->list_count) {
|
||||
$buff .= sprintf('$output->list_count = array("var"=>"%s", "value"=>$args->%s?$args->%s:"%s");%s', $output->list_count->var, $output->list_count->var, $output->list_count->var, $output->list_count->default,"\n");
|
||||
}
|
||||
|
||||
// page_count 정리
|
||||
// page_count
|
||||
if($output->page_count) {
|
||||
$buff .= sprintf('$output->page_count = array("var"=>"%s", "value"=>$args->%s?$args->%s:"%s");%s', $output->page_count->var, $output->page_count->var, $output->page_count->var, $output->list_count->default,"\n");
|
||||
}
|
||||
|
||||
// page 정리
|
||||
// page order
|
||||
if($output->page) {
|
||||
$buff .= sprintf('$output->page = array("var"=>"%s", "value"=>$args->%s?$args->%s:"%s");%s', $output->page->var, $output->page->var, $output->page->var, $output->list->default,"\n");
|
||||
}
|
||||
|
||||
// group by 정리
|
||||
// group by
|
||||
if($output->groups) {
|
||||
$buff .= sprintf('$output->groups = array("%s");%s', implode('","',$output->groups),"\n");
|
||||
}
|
||||
|
|
@ -255,7 +244,7 @@
|
|||
. $buff
|
||||
. 'return $output; ?>';
|
||||
|
||||
// 저장
|
||||
// Save
|
||||
FileHandler::writeFile($cache_file, $buff);
|
||||
}
|
||||
|
||||
|
|
@ -301,8 +290,7 @@
|
|||
* @result Returns $output
|
||||
*/
|
||||
function _setConditions($conditions){
|
||||
// 조건절 정리
|
||||
|
||||
// Conditional clause
|
||||
$condition = $conditions->condition;
|
||||
if($condition) {
|
||||
$obj->condition = $condition;
|
||||
|
|
@ -344,7 +332,7 @@
|
|||
* @result Returns $output
|
||||
*/
|
||||
function _setGroup($group_list){
|
||||
// group 정리
|
||||
// group list
|
||||
|
||||
if($group_list) {
|
||||
if(!is_array($group_list)) $group_list = array($group_list);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue