MySQL DBMS를 이용하기 위한 class. 더 자세히 ...


Public 멤버 함수 | |
| DBMysql_innodb () | |
| constructor | |
| isSupported () | |
| 설치 가능 여부를 return | |
| _setDBInfo () | |
| DB정보 설정 및 connect/ close. | |
| _connect () | |
| DB 접속. | |
| close () | |
| DB접속 해제. | |
| addQuotes ($string) | |
| 쿼리에서 입력되는 문자열 변수들의 quotation 조절 | |
| begin () | |
| 트랜잭션 시작 | |
| rollback () | |
| 롤백 | |
| commit ($force=false) | |
| 커밋 | |
| _query ($query) | |
| : 쿼리문의 실행 및 결과의 fetch 처리 | |
| _fetch ($result) | |
| 결과를 fetch | |
| getNextSequence () | |
| 1씩 증가되는 sequence값을 return (mysql의 auto_increment는 sequence테이블에서만 사용) | |
| isValidOldPassword ($password, $saved_password) | |
| mysql old password를 가져오는 함수 (mysql에서만 사용) | |
| isTableExists ($target_name) | |
| 테이블 기생성 여부 return | |
| addColumn ($table_name, $column_name, $type='number', $size='', $default= '', $notnull=false) | |
| 특정 테이블에 특정 column 추가 | |
| dropColumn ($table_name, $column_name) | |
| 특정 테이블에 특정 column 제거 | |
| isColumnExists ($table_name, $column_name) | |
| 특정 테이블의 column의 정보를 return | |
| addIndex ($table_name, $index_name, $target_columns, $is_unique=false) | |
| 특정 테이블에 특정 인덱스 추가 $target_columns = array(col1, col2) $is_unique? unique : none | |
| dropIndex ($table_name, $index_name, $is_unique=false) | |
| 특정 테이블의 특정 인덱스 삭제 | |
| isIndexExists ($table_name, $index_name) | |
| 특정 테이블의 index 정보를 return | |
| createTableByXml ($xml_doc) | |
| xml 을 받아서 테이블을 생성 | |
| createTableByXmlFile ($file_name) | |
| xml 을 받아서 테이블을 생성 | |
| _createTable ($xml_doc) | |
| schema xml을 이용하여 create table query생성 | |
| getCondition ($output) | |
| 조건문 작성하여 return | |
| getLeftCondition ($conditions, $column_type) | |
| _getCondition ($conditions, $column_type) | |
| _executeInsertAct ($output) | |
| insertAct 처리 | |
| _executeUpdateAct ($output) | |
| updateAct 처리 | |
| _executeDeleteAct ($output) | |
| deleteAct 처리 | |
| _executeSelectAct ($output) | |
| selectAct 처리 | |
| _getNavigationData ($table_list, $columns, $left_join, $condition, $output) | |
| query xml에 navigation 정보가 있을 경우 페이징 관련 작업을 처리한다 | |
Public 속성 | |
| $hostname = '127.0.0.1' | |
| Mysql DB에 접속하기 위한 정보. | |
| $userid = NULL | |
| user id | |
| $password = NULL | |
| password | |
| $database = NULL | |
| database | |
| $prefix = 'xe' | |
| XE에서 사용할 테이블들의 prefix (한 DB에서 여러개의 XE설치 가능). | |
| $column_type | |
| mysql에서 사용될 column type | |
MySQL DBMS를 이용하기 위한 class.
mysql innodb handling class
DBMysql_innodb.class.php 파일의 11 번째 라인에서 정의되었습니다.
| DBMysql_innodb::_connect | ( | ) |
DB 접속.
DBMysql_innodb.class.php 파일의 72 번째 라인에서 정의되었습니다.
다음을 참조함 : _query(), DB::setError().
다음에 의해서 참조됨 : DBMysql_innodb().
00072 { 00073 // db 정보가 없으면 무시 00074 if(!$this->hostname || !$this->userid || !$this->password || !$this->database) return; 00075 00076 if(strpos($this->hostname, ':')===false && $this->port) $this->hostname .= ':'.$this->port; 00077 00078 // 접속시도 00079 $this->fd = @mysql_connect($this->hostname, $this->userid, $this->password); 00080 if(mysql_error()) { 00081 $this->setError(mysql_errno(), mysql_error()); 00082 return; 00083 } 00084 00085 // 버전 확인후 4.1 이하면 오류 표시 00086 if(mysql_get_server_info($this->fd)<"4.1") { 00087 $this->setError(-1, "XE can not install under mysql 4.1. Current mysql version is ".mysql_get_server_info()); 00088 return; 00089 } 00090 00091 // db 선택 00092 @mysql_select_db($this->database, $this->fd); 00093 if(mysql_error()) { 00094 $this->setError(mysql_errno(), mysql_error()); 00095 return; 00096 } 00097 00098 // 접속체크 00099 $this->is_connected = true; 00100 00101 // mysql의 경우 utf8임을 지정 00102 $this->_query("set names 'utf8'"); 00103 }

| DBMysql_innodb::_createTable | ( | $ | xml_doc | ) |
schema xml을 이용하여 create table query생성
type : number, varchar, text, char, date,
opt : notnull, default, size
index : primary key, index, unique
DBMysql_innodb.class.php 파일의 331 번째 라인에서 정의되었습니다.
다음을 참조함 : $output, _query(), addQuotes(), isTableExists().
다음에 의해서 참조됨 : createTableByXml(), createTableByXmlFile().
00331 { 00332 // xml parsing 00333 $oXml = new XmlParser(); 00334 $xml_obj = $oXml->parse($xml_doc); 00335 00336 // 테이블 생성 schema 작성 00337 $table_name = $xml_obj->table->attrs->name; 00338 if($this->isTableExists($table_name)) return; 00339 $table_name = $this->prefix.$table_name; 00340 00341 if(!is_array($xml_obj->table->column)) $columns[] = $xml_obj->table->column; 00342 else $columns = $xml_obj->table->column; 00343 00344 foreach($columns as $column) { 00345 $name = $column->attrs->name; 00346 $type = $column->attrs->type; 00347 $size = $column->attrs->size; 00348 $notnull = $column->attrs->notnull; 00349 $primary_key = $column->attrs->primary_key; 00350 $index = $column->attrs->index; 00351 $unique = $column->attrs->unique; 00352 $default = $column->attrs->default; 00353 $auto_increment = $column->attrs->auto_increment; 00354 00355 $column_schema[] = sprintf('`%s` %s%s %s %s %s', 00356 $name, 00357 $this->column_type[$type], 00358 $size?'('.$size.')':'', 00359 $default?"default '".$default."'":'', 00360 $notnull?'not null':'', 00361 $auto_increment?'auto_increment':'' 00362 ); 00363 00364 if($primary_key) $primary_list[] = $name; 00365 else if($unique) $unique_list[$unique][] = $name; 00366 else if($index) $index_list[$index][] = $name; 00367 } 00368 00369 if(count($primary_list)) { 00370 $column_schema[] = sprintf("primary key (%s)", '`'.implode($primary_list,'`,`').'`'); 00371 } 00372 00373 if(count($unique_list)) { 00374 foreach($unique_list as $key => $val) { 00375 $column_schema[] = sprintf("unique %s (%s)", $key, '`'.implode($val,'`,`').'`'); 00376 } 00377 } 00378 00379 if(count($index_list)) { 00380 foreach($index_list as $key => $val) { 00381 $column_schema[] = sprintf("index %s (%s)", $key, '`'.implode($val,'`,`').'`'); 00382 } 00383 } 00384 00385 $schema = sprintf('create table `%s` (%s%s) %s;', $this->addQuotes($table_name), "\n", implode($column_schema,",\n"), "ENGINE = INNODB CHARACTER SET utf8 COLLATE utf8_general_ci"); 00386 00387 $output = $this->_query($schema); 00388 if(!$output) return false; 00389 }

| DBMysql_innodb::_executeDeleteAct | ( | $ | output | ) |
deleteAct 처리
DBMysql_innodb.class.php 파일의 495 번째 라인에서 정의되었습니다.
다음을 참조함 : $output, DB::$query, _query(), getCondition().
00495 { 00496 // 테이블 정리 00497 foreach($output->tables as $key => $val) { 00498 $table_list[] = '`'.$this->prefix.$val.'`'; 00499 } 00500 00501 // 조건절 정리 00502 $condition = $this->getCondition($output); 00503 00504 $query = sprintf("delete from %s %s", implode(',',$table_list), $condition); 00505 00506 return $this->_query($query); 00507 }

| DBMysql_innodb::_executeInsertAct | ( | $ | output | ) |
insertAct 처리
DBMysql_innodb.class.php 파일의 438 번째 라인에서 정의되었습니다.
다음을 참조함 : $output, DB::$query, _query(), elseif.
00438 { 00439 // 테이블 정리 00440 foreach($output->tables as $key => $val) { 00441 $table_list[] = '`'.$this->prefix.$val.'`'; 00442 } 00443 00444 // 컬럼 정리 00445 foreach($output->columns as $key => $val) { 00446 $name = $val['name']; 00447 $value = $val['value']; 00448 if($output->column_type[$name]!='number') { 00449 $value = "'".$this->addQuotes($value)."'"; 00450 if(!$value) $value = 'null'; 00451 } elseif(!$value || is_numeric($value)) $value = (int)$value; 00452 00453 $column_list[] = '`'.$name.'`'; 00454 $value_list[] = $value; 00455 } 00456 00457 $query = sprintf("insert into %s (%s) values (%s);", implode(',',$table_list), implode(',',$column_list), implode(',', $value_list)); 00458 return $this->_query($query); 00459 }

| DBMysql_innodb::_executeSelectAct | ( | $ | output | ) |
selectAct 처리
select의 경우 특정 페이지의 목록을 가져오는 것을 편하게 하기 위해
navigation이라는 method를 제공
DBMysql_innodb.class.php 파일의 515 번째 라인에서 정의되었습니다.
다음을 참조함 : $output, DB::$query, DB::$result, _fetch(), _getCondition(), _getNavigationData(), _query(), elseif, getCondition(), DB::getConditionList(), DB::isError().
00515 { 00516 // 테이블 정리 00517 $table_list = array(); 00518 foreach($output->tables as $key => $val) { 00519 $table_list[] = '`'.$this->prefix.$val.'` as '.$key; 00520 } 00521 00522 $left_join = array(); 00523 // why??? 00524 $left_tables= (array)$output->left_tables; 00525 00526 foreach($left_tables as $key => $val) { 00527 $condition = $this->_getCondition($output->left_conditions[$key],$output->column_type); 00528 if($condition){ 00529 $left_join[] = $val . ' `'.$this->prefix.$output->_tables[$key].'` as '.$key . ' on (' . $condition . ')'; 00530 } 00531 } 00532 00533 if(!$output->columns) { 00534 $columns = '*'; 00535 } else { 00536 $column_list = array(); 00537 foreach($output->columns as $key => $val) { 00538 $name = $val['name']; 00539 $alias = $val['alias']; 00540 if($val['click_count']) $click_count[] = $val['name']; 00541 00542 if(substr($name,-1) == '*') { 00543 $column_list[] = $name; 00544 } elseif(strpos($name,'.')===false && strpos($name,'(')===false) { 00545 if($alias) $column_list[] = sprintf('`%s` as `%s`', $name, $alias); 00546 else $column_list[] = sprintf('`%s`',$name); 00547 } else { 00548 if($alias) $column_list[] = sprintf('%s as `%s`', $name, $alias); 00549 else $column_list[] = sprintf('%s',$name); 00550 } 00551 } 00552 $columns = implode(',',$column_list); 00553 } 00554 00555 $condition = $this->getCondition($output); 00556 00557 if($output->list_count && $output->page) return $this->_getNavigationData($table_list, $columns, $left_join, $condition, $output); 00558 00559 00560 // list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가 00561 if($output->order) { 00562 $conditions = $this->getConditionList($output); 00563 if(!in_array('list_order', $conditions) && !in_array('update_order', $conditions)) { 00564 foreach($output->order as $key => $val) { 00565 $col = $val[0]; 00566 if(!in_array($col, array('list_order','update_order'))) continue; 00567 if($condition) $condition .= sprintf(' and %s < 2100000000 ', $col); 00568 else $condition = sprintf(' where %s < 2100000000 ', $col); 00569 } 00570 } 00571 } 00572 00573 $query = sprintf("select %s from %s %s %s", $columns, implode(',',$table_list),implode(' ',$left_join), $condition); 00574 00575 if(count($output->groups)) $query .= sprintf(' group by %s', implode(',',$output->groups)); 00576 00577 if($output->order) { 00578 foreach($output->order as $key => $val) { 00579 $index_list[] = sprintf('%s %s', $val[0], $val[1]); 00580 } 00581 if(count($index_list)) $query .= ' order by '.implode(',',$index_list); 00582 } 00583 00584 // list_count를 사용할 경우 적용 00585 if($output->list_count['value']) $query = sprintf('%s limit %d', $query, $output->list_count['value']); 00586 00587 $result = $this->_query($query); 00588 if($this->isError()) return; 00589 00590 if(count($click_count)>0 && count($output->conditions)>0){ 00591 $_query = ''; 00592 foreach($click_count as $k => $c) $_query .= sprintf(',%s=%s+1 ',$c,$c); 00593 $_query = sprintf('update %s set %s %s',implode(',',$table_list), substr($_query,1), $condition); 00594 $this->_query($_query); 00595 } 00596 00597 00598 $data = $this->_fetch($result); 00599 00600 $buff = new Object(); 00601 $buff->data = $data; 00602 return $buff; 00603 }

| DBMysql_innodb::_executeUpdateAct | ( | $ | output | ) |
updateAct 처리
DBMysql_innodb.class.php 파일의 464 번째 라인에서 정의되었습니다.
다음을 참조함 : $output, DB::$query, _query(), elseif, getCondition().
00464 { 00465 // 테이블 정리 00466 foreach($output->tables as $key => $val) { 00467 $table_list[] = '`'.$this->prefix.$val.'` as '.$key; 00468 } 00469 00470 // 컬럼 정리 00471 foreach($output->columns as $key => $val) { 00472 if(!isset($val['value'])) continue; 00473 $name = $val['name']; 00474 $value = $val['value']; 00475 if(strpos($name,'.')!==false&&strpos($value,'.')!==false) $column_list[] = $name.' = '.$value; 00476 else { 00477 if($output->column_type[$name]!='number') $value = "'".$this->addQuotes($value)."'"; 00478 elseif(!$value || is_numeric($value)) $value = (int)$value; 00479 00480 $column_list[] = sprintf("`%s` = %s", $name, $value); 00481 } 00482 } 00483 00484 // 조건절 정리 00485 $condition = $this->getCondition($output); 00486 00487 $query = sprintf("update %s set %s %s", implode(',',$table_list), implode(',',$column_list), $condition); 00488 00489 return $this->_query($query); 00490 }

| DBMysql_innodb::_fetch | ( | $ | result | ) |
결과를 fetch
DBMysql_innodb.class.php 파일의 181 번째 라인에서 정의되었습니다.
다음을 참조함 : $output, DB::$result, DB::isConnected(), DB::isError().
다음에 의해서 참조됨 : _executeSelectAct(), _getNavigationData(), isColumnExists(), isIndexExists(), isTableExists(), isValidOldPassword().
00181 { 00182 if(!$this->isConnected() || $this->isError() || !$result) return; 00183 while($tmp = mysql_fetch_object($result)) { 00184 $output[] = $tmp; 00185 } 00186 if(count($output)==1) return $output[0]; 00187 return $output; 00188 }

| DBMysql_innodb::_getCondition | ( | $ | conditions, | |
| $ | column_type | |||
| ) |
DBMysql_innodb.class.php 파일의 406 번째 라인에서 정의되었습니다.
다음을 참조함 : $column_type, DB::getColumnType(), DB::getConditionPart(), DB::getConditionValue().
다음에 의해서 참조됨 : _executeSelectAct(), getCondition(), getLeftCondition().
00406 { 00407 $condition = ''; 00408 foreach($conditions as $val) { 00409 $sub_condition = ''; 00410 foreach($val['condition'] as $v) { 00411 if(!isset($v['value'])) continue; 00412 if($v['value'] === '') continue; 00413 if(!in_array(gettype($v['value']), array('string', 'integer'))) continue; 00414 00415 $name = $v['column']; 00416 $operation = $v['operation']; 00417 $value = $v['value']; 00418 $type = $this->getColumnType($column_type,$name); 00419 $pipe = $v['pipe']; 00420 00421 $value = $this->getConditionValue($name, $value, $operation, $type, $column_type); 00422 if(!$value) $value = $v['value']; 00423 $str = $this->getConditionPart($name, $value, $operation); 00424 if($sub_condition) $sub_condition .= ' '.$pipe.' '; 00425 $sub_condition .= $str; 00426 } 00427 if($sub_condition) { 00428 if($condition && $val['pipe']) $condition .= ' '.$val['pipe'].' '; 00429 $condition .= '('.$sub_condition.')'; 00430 } 00431 } 00432 return $condition; 00433 }

| DBMysql_innodb::_getNavigationData | ( | $ | table_list, | |
| $ | columns, | |||
| $ | left_join, | |||
| $ | condition, | |||
| $ | output | |||
| ) |
query xml에 navigation 정보가 있을 경우 페이징 관련 작업을 처리한다
그닥 좋지는 않은 구조이지만 편리하다.. -_-;
DBMysql_innodb.class.php 파일의 610 번째 라인에서 정의되었습니다.
다음을 참조함 : $output, DB::$query, DB::$result, _fetch(), _query(), DB::getConditionList(), DB::getCountCache(), DB::isError().
다음에 의해서 참조됨 : _executeSelectAct().
00610 { 00611 require_once(_XE_PATH_.'classes/page/PageHandler.class.php'); 00612 00613 // 전체 개수를 구함 00614 $count_condition = count($output->groups) ? sprintf('%s group by %s', $condition, implode(', ', $output->groups)) : $condition; 00615 $total_count = $this->getCountCache($output->tables, $count_condition); 00616 if($total_count === false) { 00617 $count_query = sprintf("select count(*) as count from %s %s %s", implode(', ', $table_list), implode(' ', $left_join), $count_condition); 00618 if (count($output->groups)) 00619 $count_query = sprintf('select count(*) as count from (%s) xet', $count_query); 00620 $result = $this->_query($count_query); 00621 $count_output = $this->_fetch($result); 00622 $total_count = (int)$count_output->count; 00623 $this->putCountCache($output->tables, $count_condition, $total_count); 00624 } 00625 00626 $list_count = $output->list_count['value']; 00627 if(!$list_count) $list_count = 20; 00628 $page_count = $output->page_count['value']; 00629 if(!$page_count) $page_count = 10; 00630 $page = $output->page['value']; 00631 if(!$page) $page = 1; 00632 00633 // 전체 페이지를 구함 00634 if($total_count) $total_page = (int)( ($total_count-1) / $list_count) + 1; 00635 else $total_page = 1; 00636 00637 // 페이지 변수를 체크 00638 if($page > $total_page) $page = $total_page; 00639 $start_count = ($page-1)*$list_count; 00640 00641 // list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가 00642 if($output->order) { 00643 $conditions = $this->getConditionList($output); 00644 if(!in_array('list_order', $conditions) && !in_array('update_order', $conditions)) { 00645 foreach($output->order as $key => $val) { 00646 $col = $val[0]; 00647 if(!in_array($col, array('list_order','update_order'))) continue; 00648 if($condition) $condition .= sprintf(' and %s < 2100000000 ', $col); 00649 else $condition = sprintf(' where %s < 2100000000 ', $col); 00650 } 00651 } 00652 } 00653 00654 $query = sprintf("select %s from %s %s %s", $columns, implode(',',$table_list), implode(' ',$left_join), $condition); 00655 if(count($output->groups)) $query .= sprintf(' group by %s', implode(',',$output->groups)); 00656 00657 if($output->order) { 00658 foreach($output->order as $key => $val) { 00659 $index_list[] = sprintf('%s %s', $val[0], $val[1]); 00660 } 00661 if(count($index_list)) $query .= ' order by '.implode(',',$index_list); 00662 } 00663 00664 $query = sprintf('%s limit %d, %d', $query, $start_count, $list_count); 00665 00666 $result = $this->_query($query); 00667 if($this->isError()) { 00668 $buff = new Object(); 00669 $buff->total_count = 0; 00670 $buff->total_page = 0; 00671 $buff->page = 1; 00672 $buff->data = array(); 00673 00674 $buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count); 00675 return $buff; 00676 } 00677 00678 $virtual_no = $total_count - ($page-1)*$list_count; 00679 while($tmp = mysql_fetch_object($result)) { 00680 $data[$virtual_no--] = $tmp; 00681 } 00682 00683 $buff = new Object(); 00684 $buff->total_count = $total_count; 00685 $buff->total_page = $total_page; 00686 $buff->page = $page; 00687 $buff->data = $data; 00688 00689 $buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count); 00690 return $buff; 00691 }

| DBMysql_innodb::_query | ( | $ | query | ) |
: 쿼리문의 실행 및 결과의 fetch 처리
query : query문 실행하고 result return
fetch : reutrn 된 값이 없으면 NULL
rows이면 array object
row이면 object
return
DBMysql_innodb.class.php 파일의 159 번째 라인에서 정의되었습니다.
다음을 참조함 : DB::$query, DB::$result, DB::actFinish(), DB::actStart(), DB::isConnected(), DB::setError().
다음에 의해서 참조됨 : _connect(), _createTable(), _executeDeleteAct(), _executeInsertAct(), _executeSelectAct(), _executeUpdateAct(), _getNavigationData(), addColumn(), addIndex(), begin(), close(), commit(), dropColumn(), dropIndex(), getNextSequence(), isColumnExists(), isIndexExists(), isTableExists(), isValidOldPassword(), rollback().
00159 { 00160 if(!$this->isConnected()) return; 00161 00162 // 쿼리 시작을 알림 00163 $this->actStart($query); 00164 00165 // 쿼리 문 실행 00166 $result = @mysql_query($query, $this->fd); 00167 00168 // 오류 체크 00169 if(mysql_error($this->fd)) $this->setError(mysql_errno($this->fd), mysql_error($this->fd)); 00170 00171 // 쿼리 실행 종료를 알림 00172 $this->actFinish(); 00173 00174 // 결과 리턴 00175 return $result; 00176 }

| DBMysql_innodb::_setDBInfo | ( | ) |
DB정보 설정 및 connect/ close.
DBMysql_innodb.class.php 파일의 58 번째 라인에서 정의되었습니다.
다음을 참조함 : Context::getDBInfo().
다음에 의해서 참조됨 : DBMysql_innodb().
00058 { 00059 $db_info = Context::getDBInfo(); 00060 $this->hostname = $db_info->db_hostname; 00061 $this->port = $db_info->db_port; 00062 $this->userid = $db_info->db_userid; 00063 $this->password = $db_info->db_password; 00064 $this->database = $db_info->db_database; 00065 $this->prefix = $db_info->db_table_prefix; 00066 if(!substr($this->prefix,-1)!='_') $this->prefix .= '_'; 00067 }

| DBMysql_innodb::addColumn | ( | $ | table_name, | |
| $ | column_name, | |||
| $ | type = 'number', |
|||
| $ | size = '', |
|||
| $ | default = '', |
|||
| $ | notnull = false | |||
| ) |
특정 테이블에 특정 column 추가
DBMysql_innodb.class.php 파일의 230 번째 라인에서 정의되었습니다.
다음을 참조함 : DB::$query, _query().
00230 { 00231 $type = $this->column_type[$type]; 00232 if(strtoupper($type)=='INTEGER') $size = ''; 00233 00234 $query = sprintf("alter table %s%s add %s ", $this->prefix, $table_name, $column_name); 00235 if($size) $query .= sprintf(" %s(%s) ", $type, $size); 00236 else $query .= sprintf(" %s ", $type); 00237 if($default) $query .= sprintf(" default '%s' ", $default); 00238 if($notnull) $query .= " not null "; 00239 00240 $this->_query($query); 00241 }

| DBMysql_innodb::addIndex | ( | $ | table_name, | |
| $ | index_name, | |||
| $ | target_columns, | |||
| $ | is_unique = false | |||
| ) |
특정 테이블에 특정 인덱스 추가 $target_columns = array(col1, col2) $is_unique? unique : none
DBMysql_innodb.class.php 파일의 274 번째 라인에서 정의되었습니다.
다음을 참조함 : DB::$query, _query().
00274 { 00275 if(!is_array($target_columns)) $target_columns = array($target_columns); 00276 00277 $query = sprintf("alter table %s%s add %s index %s (%s);", $this->prefix, $table_name, $is_unique?'unique':'', $index_name, implode(',',$target_columns)); 00278 $this->_query($query); 00279 }

| DBMysql_innodb::addQuotes | ( | $ | string | ) |
쿼리에서 입력되는 문자열 변수들의 quotation 조절
DBMysql_innodb.class.php 파일의 117 번째 라인에서 정의되었습니다.
다음에 의해서 참조됨 : _createTable(), isTableExists(), isValidOldPassword().
| DBMysql_innodb::begin | ( | ) |
트랜잭션 시작
DBMysql_innodb.class.php 파일의 126 번째 라인에서 정의되었습니다.
다음을 참조함 : _query(), DB::isConnected().
00126 { 00127 if(!$this->isConnected() || $this->transaction_started) return; 00128 $this->transaction_started = true; 00129 $this->_query("begin"); 00130 }

| DBMysql_innodb::close | ( | ) |
DB접속 해제.
DBMysql_innodb.class.php 파일의 108 번째 라인에서 정의되었습니다.
다음을 참조함 : _query(), DB::isConnected().
00108 { 00109 if(!$this->isConnected()) return; 00110 $this->_query("commit"); 00111 @mysql_close($this->fd); 00112 }

| DBMysql_innodb::commit | ( | $ | force = false |
) |
커밋
DBMysql_innodb.class.php 파일의 144 번째 라인에서 정의되었습니다.
다음을 참조함 : _query(), DB::isConnected().
00144 { 00145 if(!$force && (!$this->isConnected() || !$this->transaction_started)) return; 00146 $this->_query("commit"); 00147 $this->transaction_started = false; 00148 }

| DBMysql_innodb::createTableByXml | ( | $ | xml_doc | ) |
xml 을 받아서 테이블을 생성
DBMysql_innodb.class.php 파일의 310 번째 라인에서 정의되었습니다.
다음을 참조함 : _createTable().
00310 { 00311 return $this->_createTable($xml_doc); 00312 }

| DBMysql_innodb::createTableByXmlFile | ( | $ | file_name | ) |
xml 을 받아서 테이블을 생성
DBMysql_innodb.class.php 파일의 317 번째 라인에서 정의되었습니다.
다음을 참조함 : _createTable(), FileHandler::readFile().
00317 { 00318 if(!file_exists($file_name)) return; 00319 // xml 파일을 읽음 00320 $buff = FileHandler::readFile($file_name); 00321 return $this->_createTable($buff); 00322 }

| DBMysql_innodb::DBMysql_innodb | ( | ) |
constructor
DBMysql_innodb.class.php 파일의 42 번째 라인에서 정의되었습니다.
다음을 참조함 : _connect(), _setDBInfo().
00042 { 00043 $this->_setDBInfo(); 00044 $this->_connect(); 00045 }

| DBMysql_innodb::dropColumn | ( | $ | table_name, | |
| $ | column_name | |||
| ) |
특정 테이블에 특정 column 제거
DBMysql_innodb.class.php 파일의 246 번째 라인에서 정의되었습니다.
다음을 참조함 : DB::$query, _query().
00246 { 00247 $query = sprintf("alter table %s%s drop %s ", $this->prefix, $table_name, $column_name); 00248 $this->_query($query); 00249 }

| DBMysql_innodb::dropIndex | ( | $ | table_name, | |
| $ | index_name, | |||
| $ | is_unique = false | |||
| ) |
특정 테이블의 특정 인덱스 삭제
DBMysql_innodb.class.php 파일의 284 번째 라인에서 정의되었습니다.
다음을 참조함 : DB::$query, _query().
00284 { 00285 $query = sprintf("alter table %s%s drop index %s;", $this->prefix, $table_name, $index_name); 00286 $this->_query($query); 00287 }

| DBMysql_innodb::getCondition | ( | $ | output | ) |
조건문 작성하여 return
DBMysql_innodb.class.php 파일의 394 번째 라인에서 정의되었습니다.
다음을 참조함 : $output, _getCondition().
다음에 의해서 참조됨 : _executeDeleteAct(), _executeSelectAct(), _executeUpdateAct().
00394 { 00395 if(!$output->conditions) return; 00396 $condition = $this->_getCondition($output->conditions,$output->column_type); 00397 if($condition) $condition = ' where '.$condition; 00398 return $condition; 00399 }

| DBMysql_innodb::getLeftCondition | ( | $ | conditions, | |
| $ | column_type | |||
| ) |
DBMysql_innodb.class.php 파일의 401 번째 라인에서 정의되었습니다.
다음을 참조함 : $column_type, _getCondition().
00401 { 00402 return $this->_getCondition($conditions,$column_type); 00403 }

| DBMysql_innodb::getNextSequence | ( | ) |
1씩 증가되는 sequence값을 return (mysql의 auto_increment는 sequence테이블에서만 사용)
DBMysql_innodb.class.php 파일의 193 번째 라인에서 정의되었습니다.
다음을 참조함 : DB::$query, _query().
00193 { 00194 $query = sprintf("insert into `%ssequence` (seq) values ('0')", $this->prefix); 00195 $this->_query($query); 00196 $sequence = mysql_insert_id($this->fd); 00197 if($sequence % 10000 == 0) { 00198 $query = sprintf("delete from `%ssequence` where seq < %d", $this->prefix, $sequence); 00199 $this->_query($query); 00200 } 00201 00202 return $sequence; 00203 }

| DBMysql_innodb::isColumnExists | ( | $ | table_name, | |
| $ | column_name | |||
| ) |
특정 테이블의 column의 정보를 return
DBMysql_innodb.class.php 파일의 254 번째 라인에서 정의되었습니다.
다음을 참조함 : $output, DB::$query, DB::$result, _fetch(), _query(), DB::isError().
00254 { 00255 $query = sprintf("show fields from %s%s", $this->prefix, $table_name); 00256 $result = $this->_query($query); 00257 if($this->isError()) return; 00258 $output = $this->_fetch($result); 00259 if($output) { 00260 $column_name = strtolower($column_name); 00261 foreach($output as $key => $val) { 00262 $name = strtolower($val->Field); 00263 if($column_name == $name) return true; 00264 } 00265 } 00266 return false; 00267 }

| DBMysql_innodb::isIndexExists | ( | $ | table_name, | |
| $ | index_name | |||
| ) |
특정 테이블의 index 정보를 return
DBMysql_innodb.class.php 파일의 292 번째 라인에서 정의되었습니다.
다음을 참조함 : $output, DB::$query, DB::$result, _fetch(), _query(), DB::isError().
00292 { 00293 //$query = sprintf("show indexes from %s%s where key_name = '%s' ", $this->prefix, $table_name, $index_name); 00294 $query = sprintf("show indexes from %s%s", $this->prefix, $table_name); 00295 $result = $this->_query($query); 00296 if($this->isError()) return; 00297 $output = $this->_fetch($result); 00298 if(!$output) return; 00299 if(!is_array($output)) $output = array($output); 00300 00301 for($i=0;$i<count($output);$i++) { 00302 if($output[$i]->Key_name == $index_name) return true; 00303 } 00304 return false; 00305 }

| DBMysql_innodb::isSupported | ( | ) |
설치 가능 여부를 return
DBMysql_innodb.class.php 파일의 50 번째 라인에서 정의되었습니다.
| DBMysql_innodb::isTableExists | ( | $ | target_name | ) |
테이블 기생성 여부 return
DBMysql_innodb.class.php 파일의 219 번째 라인에서 정의되었습니다.
다음을 참조함 : DB::$query, DB::$result, _fetch(), _query(), addQuotes().
다음에 의해서 참조됨 : _createTable().
00219 { 00220 $query = sprintf("show tables like '%s%s'", $this->prefix, $this->addQuotes($target_name)); 00221 $result = $this->_query($query); 00222 $tmp = $this->_fetch($result); 00223 if(!$tmp) return false; 00224 return true; 00225 }

| DBMysql_innodb::isValidOldPassword | ( | $ | password, | |
| $ | saved_password | |||
| ) |
mysql old password를 가져오는 함수 (mysql에서만 사용)
DBMysql_innodb.class.php 파일의 208 번째 라인에서 정의되었습니다.
다음을 참조함 : $password, DB::$query, DB::$result, _fetch(), _query(), addQuotes().
00208 { 00209 $query = sprintf("select password('%s') as password, old_password('%s') as old_password", $this->addQuotes($password), $this->addQuotes($password)); 00210 $result = $this->_query($query); 00211 $tmp = $this->_fetch($result); 00212 if($tmp->password == $saved_password || $tmp->old_password == $saved_password) return true; 00213 return false; 00214 }

| DBMysql_innodb::rollback | ( | ) |
롤백
DBMysql_innodb.class.php 파일의 135 번째 라인에서 정의되었습니다.
다음을 참조함 : _query(), DB::isConnected().
00135 { 00136 if(!$this->isConnected() || !$this->transaction_started) return; 00137 $this->_query("rollback"); 00138 $this->transaction_started = false; 00139 }

| DBMysql_innodb::$column_type |
array(
'bignumber' => 'bigint',
'number' => 'bigint',
'varchar' => 'varchar',
'char' => 'char',
'text' => 'text',
'bigtext' => 'longtext',
'date' => 'varchar(14)',
'float' => 'float',
)
mysql에서 사용될 column type
column_type은 schema/query xml에서 공통 선언된 type을 이용하기 때문에 각 DBMS에 맞게 replace 해주어야 한다
DBMysql_innodb.class.php 파일의 28 번째 라인에서 정의되었습니다.
다음에 의해서 참조됨 : _getCondition(), getLeftCondition().
| DBMysql_innodb::$database = NULL |
database
DBMysql_innodb.class.php 파일의 19 번째 라인에서 정의되었습니다.
| DBMysql_innodb::$hostname = '127.0.0.1' |
| DBMysql_innodb::$password = NULL |
| DBMysql_innodb::$prefix = 'xe' |
XE에서 사용할 테이블들의 prefix (한 DB에서 여러개의 XE설치 가능).
DBMysql_innodb.class.php 파일의 20 번째 라인에서 정의되었습니다.
| DBMysql_innodb::$userid = NULL |
user id
DBMysql_innodb.class.php 파일의 17 번째 라인에서 정의되었습니다.
1.6.1