DBMysql 클래스 참조

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

DBMysql에 대한 상속 다이어그램 :
Inheritance graph
DBMysql에 대한 협력 다이어그램:
Collaboration graph

모든 멤버 목록

Public 멤버 함수

 DBMysql ()
 constructor
 isSupported ()
 설치 가능 여부를 return
 _setDBInfo ()
 DB정보 설정 및 connect/ close.
 _connect ()
 DB 접속.
 close ()
 DB접속 해제.
 addQuotes ($string)
 쿼리에서 입력되는 문자열 변수들의 quotation 조절
 begin ()
 트랜잭션 시작
 rollback ()
 롤백
 commit ()
 커밋
 _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.

작성자:
zero (zero@nzeo.com)
버전:
0.1

mysql handling class

DBMysql.class.php 파일의 11 번째 라인에서 정의되었습니다.


멤버 함수 문서화

DBMysql::_connect (  ) 

DB 접속.

DBMysql.class.php 파일의 72 번째 라인에서 정의되었습니다.

다음을 참조함 : _query(), DB::setError().

다음에 의해서 참조됨 : DBMysql().

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 cannot be installed under the version of 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::_createTable ( xml_doc  ) 

schema xml을 이용하여 create table query생성

type : number, varchar, text, char, date,
opt : notnull, default, size
index : primary key, index, unique

DBMysql.class.php 파일의 322 번째 라인에서 정의되었습니다.

다음을 참조함 : $output, _query(), addQuotes(), isTableExists().

다음에 의해서 참조됨 : createTableByXml(), createTableByXmlFile().

00322                                         {
00323             // xml parsing
00324             $oXml = new XmlParser();
00325             $xml_obj = $oXml->parse($xml_doc);
00326 
00327             // 테이블 생성 schema 작성
00328             $table_name = $xml_obj->table->attrs->name;
00329             if($this->isTableExists($table_name)) return;
00330             $table_name = $this->prefix.$table_name;
00331 
00332             if(!is_array($xml_obj->table->column)) $columns[] = $xml_obj->table->column;
00333             else $columns = $xml_obj->table->column;
00334 
00335             foreach($columns as $column) {
00336                 $name = $column->attrs->name;
00337                 $type = $column->attrs->type;
00338                 $size = $column->attrs->size;
00339                 $notnull = $column->attrs->notnull;
00340                 $primary_key = $column->attrs->primary_key;
00341                 $index = $column->attrs->index;
00342                 $unique = $column->attrs->unique;
00343                 $default = $column->attrs->default;
00344                 $auto_increment = $column->attrs->auto_increment;
00345 
00346                 $column_schema[] = sprintf('`%s` %s%s %s %s %s',
00347                     $name,
00348                     $this->column_type[$type],
00349                     $size?'('.$size.')':'',
00350                     $default?"default '".$default."'":'',
00351                     $notnull?'not null':'',
00352                     $auto_increment?'auto_increment':''
00353                 );
00354 
00355                 if($primary_key) $primary_list[] = $name;
00356                 else if($unique) $unique_list[$unique][] = $name;
00357                 else if($index) $index_list[$index][] = $name;
00358             }
00359 
00360             if(count($primary_list)) {
00361                 $column_schema[] = sprintf("primary key (%s)", '`'.implode($primary_list,'`,`').'`');
00362             }
00363 
00364             if(count($unique_list)) {
00365                 foreach($unique_list as $key => $val) {
00366                     $column_schema[] = sprintf("unique %s (%s)", $key, '`'.implode($val,'`,`').'`');
00367                 }
00368             }
00369 
00370             if(count($index_list)) {
00371                 foreach($index_list as $key => $val) {
00372                     $column_schema[] = sprintf("index %s (%s)", $key, '`'.implode($val,'`,`').'`');
00373                 }
00374             }
00375 
00376             $schema = sprintf('create table `%s` (%s%s) %s;', $this->addQuotes($table_name), "\n", implode($column_schema,",\n"), "ENGINE = MYISAM  CHARACTER SET utf8 COLLATE utf8_general_ci");
00377 
00378             $output = $this->_query($schema);
00379             if(!$output) return false;
00380         }

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

DBMysql::_executeDeleteAct ( output  ) 

deleteAct 처리

DBMysql.class.php 파일의 485 번째 라인에서 정의되었습니다.

다음을 참조함 : $output, DB::$query, _query(), getCondition().

00485                                             {
00486             // 테이블 정리
00487             foreach($output->tables as $key => $val) {
00488                 $table_list[] = '`'.$this->prefix.$val.'`';
00489             }
00490 
00491             // 조건절 정리
00492             $condition = $this->getCondition($output);
00493 
00494             $query = sprintf("delete from %s %s", implode(',',$table_list), $condition);
00495 
00496             return $this->_query($query);
00497         }

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

DBMysql::_executeInsertAct ( output  ) 

insertAct 처리

DBMysql.class.php 파일의 428 번째 라인에서 정의되었습니다.

다음을 참조함 : $output, DB::$query, _query(), elseif.

00428                                             {
00429             // 테이블 정리
00430             foreach($output->tables as $key => $val) {
00431                 $table_list[] = '`'.$this->prefix.$val.'`';
00432             }
00433 
00434             // 컬럼 정리 
00435             foreach($output->columns as $key => $val) {
00436                 $name = $val['name'];
00437                 $value = $val['value'];
00438                 if($output->column_type[$name]!='number') {
00439                     $value = "'".$this->addQuotes($value)."'";
00440                     if(!$value) $value = 'null';
00441                 } elseif(!$value || is_numeric($value)) $value = (int)$value;
00442 
00443                 $column_list[] = '`'.$name.'`';
00444                 $value_list[] = $value;
00445             }
00446 
00447             $query = sprintf("insert into %s (%s) values (%s);", implode(',',$table_list), implode(',',$column_list), implode(',', $value_list));
00448             return $this->_query($query);
00449         }

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

DBMysql::_executeSelectAct ( output  ) 

selectAct 처리

select의 경우 특정 페이지의 목록을 가져오는 것을 편하게 하기 위해
navigation이라는 method를 제공

DBMysql.class.php 파일의 505 번째 라인에서 정의되었습니다.

다음을 참조함 : $output, DB::$query, DB::$result, _fetch(), _getCondition(), _getNavigationData(), _query(), elseif, getCondition(), DB::getConditionList(), DB::isError().

00505                                             {
00506             // 테이블 정리
00507             $table_list = array();
00508             foreach($output->tables as $key => $val) {
00509                 $table_list[] = '`'.$this->prefix.$val.'` as '.$key;
00510             }
00511 
00512             $left_join = array();
00513             // why???
00514             $left_tables= (array)$output->left_tables;
00515             foreach($left_tables as $key => $val) {
00516                 $condition = $this->_getCondition($output->left_conditions[$key],$output->column_type);
00517                 if($condition){
00518                     $left_join[] = $val . ' `'.$this->prefix.$output->_tables[$key].'` as '.$key  . ' on (' . $condition . ')';
00519                 }
00520             }
00521 
00522             $click_count = array();
00523             if(!$output->columns) {
00524                 $columns = '*';
00525             } else {
00526                 $column_list = array();
00527                 foreach($output->columns as $key => $val) {
00528                     $name = $val['name'];
00529                     $alias = $val['alias'];
00530                     if($val['click_count']) $click_count[] = $val['name'];
00531 
00532                     if(substr($name,-1) == '*') {
00533                         $column_list[] = $name;
00534                     } elseif(strpos($name,'.')===false && strpos($name,'(')===false) {
00535                         if($alias) $column_list[] = sprintf('`%s` as `%s`', $name, $alias);
00536                         else $column_list[] = sprintf('`%s`',$name);
00537                     } else {
00538                         if($alias) $column_list[] = sprintf('%s as `%s`', $name, $alias);
00539                         else $column_list[] = sprintf('%s',$name);
00540                     }
00541                 }
00542                 $columns = implode(',',$column_list);
00543             }
00544 
00545             $condition = $this->getCondition($output);
00546 
00547             if($output->list_count && $output->page) return $this->_getNavigationData($table_list, $columns, $left_join, $condition, $output);
00548 
00549             // list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가
00550             if($output->order) {
00551                 $conditions = $this->getConditionList($output);
00552                 if(!in_array('list_order', $conditions) && !in_array('update_order', $conditions)) {
00553                     foreach($output->order as $key => $val) {
00554                         $col = $val[0];
00555                         if(!in_array($col, array('list_order','update_order'))) continue;
00556                         if($condition) $condition .= sprintf(' and %s < 2100000000 ', $col);
00557                         else $condition = sprintf(' where %s < 2100000000 ', $col);
00558                     }
00559                 }
00560             }
00561 
00562             $query = sprintf("select %s from %s %s %s", $columns, implode(',',$table_list),implode(' ',$left_join), $condition);
00563 
00564             if(count($output->groups)) $query .= sprintf(' group by %s', implode(',',$output->groups));
00565 
00566             if($output->order) {
00567                 foreach($output->order as $key => $val) {
00568                     $index_list[] = sprintf('%s %s', $val[0], $val[1]);
00569                 }
00570                 if(count($index_list)) $query .= ' order by '.implode(',',$index_list);
00571             }
00572 
00573             // list_count를 사용할 경우 적용
00574             if($output->list_count['value']) $query = sprintf('%s limit %d', $query, $output->list_count['value']);
00575 
00576             $result = $this->_query($query);
00577             if($this->isError()) return;
00578 
00579             if(count($click_count)>0 && count($output->conditions)>0){
00580                 $_query = '';
00581                 foreach($click_count as $k => $c) $_query .= sprintf(',%s=%s+1 ',$c,$c);
00582                 $_query = sprintf('update %s set %s %s',implode(',',$table_list), substr($_query,1),  $condition);
00583                 $this->_query($_query);
00584             }
00585 
00586             $data = $this->_fetch($result);
00587 
00588             $buff = new Object();
00589             $buff->data = $data;
00590             return $buff;
00591         }

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

DBMysql::_executeUpdateAct ( output  ) 

updateAct 처리

DBMysql.class.php 파일의 454 번째 라인에서 정의되었습니다.

다음을 참조함 : $output, DB::$query, _query(), elseif, getCondition().

00454                                             {
00455             // 테이블 정리
00456             foreach($output->tables as $key => $val) {
00457                 $table_list[] = '`'.$this->prefix.$val.'` as '.$key;
00458             }
00459 
00460             // 컬럼 정리 
00461             foreach($output->columns as $key => $val) {
00462                 if(!isset($val['value'])) continue;
00463                 $name = $val['name'];
00464                 $value = $val['value'];
00465                 if(strpos($name,'.')!==false&&strpos($value,'.')!==false) $column_list[] = $name.' = '.$value;
00466                 else {
00467                     if($output->column_type[$name]!='number') $value = "'".$this->addQuotes($value)."'";
00468                     elseif(!$value || is_numeric($value)) $value = (int)$value;
00469 
00470                     $column_list[] = sprintf("`%s` = %s", $name, $value);
00471                 }
00472             }
00473 
00474             // 조건절 정리
00475             $condition = $this->getCondition($output);
00476 
00477             $query = sprintf("update %s set %s %s", implode(',',$table_list), implode(',',$column_list), $condition);
00478 
00479             return $this->_query($query);
00480         }

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

DBMysql::_fetch ( result  ) 

결과를 fetch

DBMysql.class.php 파일의 171 번째 라인에서 정의되었습니다.

다음을 참조함 : $output, DB::$result, DB::isConnected(), DB::isError().

다음에 의해서 참조됨 : _executeSelectAct(), _getNavigationData(), isColumnExists(), isIndexExists(), isTableExists(), isValidOldPassword().

00171                                  {
00172             if(!$this->isConnected() || $this->isError() || !$result) return;
00173             while($tmp = mysql_fetch_object($result)) {
00174                 $output[] = $tmp;
00175             }
00176             if(count($output)==1) return $output[0];
00177             return $output;
00178         }

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

DBMysql::_getCondition ( conditions,
column_type 
)

DBMysql.class.php 파일의 397 번째 라인에서 정의되었습니다.

다음을 참조함 : $column_type, DB::getColumnType(), DB::getConditionPart(), DB::getConditionValue().

다음에 의해서 참조됨 : _executeSelectAct(), getCondition(), getLeftCondition().

00397                                                          {
00398             $condition = '';
00399             foreach($conditions as $val) {
00400                 $sub_condition = '';
00401                 foreach($val['condition'] as $v) {
00402                     if(!isset($v['value'])) continue;
00403                     if($v['value'] === '') continue;
00404                     if(!in_array(gettype($v['value']), array('string', 'integer'))) continue;
00405 
00406                     $name = $v['column'];
00407                     $operation = $v['operation'];
00408                     $value = $v['value'];
00409                     $type = $this->getColumnType($column_type,$name);
00410                     $pipe = $v['pipe'];
00411                     $value = $this->getConditionValue($name, $value, $operation, $type, $column_type);
00412                     if(!$value) $value = $v['value'];
00413                     $str = $this->getConditionPart($name, $value, $operation);
00414                     if($sub_condition) $sub_condition .= ' '.$pipe.' ';
00415                     $sub_condition .=  $str;
00416                 }
00417                 if($sub_condition) {
00418                     if($condition && $val['pipe']) $condition .= ' '.$val['pipe'].' ';
00419                     $condition .= '('.$sub_condition.')';
00420                 }
00421             }
00422             return $condition;
00423         }

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

DBMysql::_getNavigationData ( table_list,
columns,
left_join,
condition,
output 
)

query xml에 navigation 정보가 있을 경우 페이징 관련 작업을 처리한다

그닥 좋지는 않은 구조이지만 편리하다.. -_-;

DBMysql.class.php 파일의 598 번째 라인에서 정의되었습니다.

다음을 참조함 : $output, DB::$query, DB::$result, _fetch(), _query(), DB::getConditionList(), DB::getCountCache(), DB::isError().

다음에 의해서 참조됨 : _executeSelectAct().

00598                                                                                             {
00599             require_once(_XE_PATH_.'classes/page/PageHandler.class.php');
00600 
00601             // 전체 개수를 구함
00602             $count_condition = count($output->groups) ? sprintf('%s group by %s', $condition, implode(', ', $output->groups)) : $condition;
00603             $total_count = $this->getCountCache($output->tables, $count_condition);
00604             if($total_count === false) {
00605                 $count_query = sprintf("select count(*) as count from %s %s %s", implode(', ', $table_list), implode(' ', $left_join), $count_condition);
00606                 if (count($output->groups))
00607                     $count_query = sprintf('select count(*) as count from (%s) xet', $count_query);
00608                 $result = $this->_query($count_query);
00609                 $count_output = $this->_fetch($result);
00610                 $total_count = (int)$count_output->count;
00611                 $this->putCountCache($output->tables, $count_condition, $total_count);
00612             }
00613 
00614             $list_count = $output->list_count['value'];
00615             if(!$list_count) $list_count = 20;
00616             $page_count = $output->page_count['value'];
00617             if(!$page_count) $page_count = 10;
00618             $page = $output->page['value'];
00619             if(!$page) $page = 1;
00620 
00621             // 전체 페이지를 구함
00622             if($total_count) $total_page = (int)( ($total_count-1) / $list_count) + 1;
00623             else $total_page = 1;
00624 
00625             // 페이지 변수를 체크
00626             if($page > $total_page) $page = $total_page;
00627             $start_count = ($page-1)*$list_count;
00628 
00629             // list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가
00630             if($output->order) {
00631                 $conditions = $this->getConditionList($output);
00632                 if(!in_array('list_order', $conditions) && !in_array('update_order', $conditions)) {
00633                     foreach($output->order as $key => $val) {
00634                         $col = $val[0];
00635                         if(!in_array($col, array('list_order','update_order'))) continue;
00636                         if($condition) $condition .= sprintf(' and %s < 2100000000 ', $col);
00637                         else $condition = sprintf(' where %s < 2100000000 ', $col);
00638                     }
00639                 }
00640             }
00641 
00642             $query = sprintf("select %s from %s %s %s", $columns, implode(',',$table_list), implode(' ',$left_join), $condition);
00643 
00644             if(count($output->groups)) $query .= sprintf(' group by %s', implode(',',$output->groups));
00645 
00646             if(count($output->order)) {
00647                 foreach($output->order as $key => $val) {
00648                     $index_list[] = sprintf('%s %s', $val[0], $val[1]);
00649                 }
00650                 if(count($index_list)) $query .= ' order by '.implode(',',$index_list);
00651             }
00652 
00653             $query = sprintf('%s limit %d, %d', $query, $start_count, $list_count);
00654             $result = $this->_query($query);
00655             if($this->isError()) {
00656                 $buff = new Object();
00657                 $buff->total_count = 0;
00658                 $buff->total_page = 0;
00659                 $buff->page = 1;
00660                 $buff->data = array();
00661 
00662                 $buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count);
00663                 return $buff;
00664             }
00665 
00666             $virtual_no = $total_count - ($page-1)*$list_count;
00667             while($tmp = mysql_fetch_object($result)) {
00668                 $data[$virtual_no--] = $tmp;
00669             }
00670 
00671             $buff = new Object();
00672             $buff->total_count = $total_count;
00673             $buff->total_page = $total_page;
00674             $buff->page = $page;
00675             $buff->data = $data;
00676 
00677             $buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count);
00678             return $buff;
00679         }

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

DBMysql::_query ( query  ) 

: 쿼리문의 실행 및 결과의 fetch 처리

query : query문 실행하고 result return
fetch : reutrn 된 값이 없으면 NULL
rows이면 array object
row이면 object
return

DBMysql.class.php 파일의 149 번째 라인에서 정의되었습니다.

다음을 참조함 : DB::$query, DB::$result, DB::actFinish(), DB::actStart(), DB::isConnected(), DB::setError().

다음에 의해서 참조됨 : _connect(), _createTable(), _executeDeleteAct(), _executeInsertAct(), _executeSelectAct(), _executeUpdateAct(), _getNavigationData(), addColumn(), addIndex(), dropColumn(), dropIndex(), getNextSequence(), isColumnExists(), isIndexExists(), isTableExists(), isValidOldPassword().

00149                                 {
00150             if(!$this->isConnected()) return;
00151 
00152             // 쿼리 시작을 알림
00153             $this->actStart($query);
00154 
00155             // 쿼리 문 실행
00156             $result = @mysql_query($query, $this->fd);
00157 
00158             // 오류 체크
00159             if(mysql_error($this->fd)) $this->setError(mysql_errno($this->fd), mysql_error($this->fd));
00160 
00161             // 쿼리 실행 종료를 알림
00162             $this->actFinish();
00163 
00164             // 결과 리턴
00165             return $result;
00166         }

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

DBMysql::_setDBInfo (  ) 

DB정보 설정 및 connect/ close.

DBMysql.class.php 파일의 58 번째 라인에서 정의되었습니다.

다음을 참조함 : Context::getDBInfo().

다음에 의해서 참조됨 : DBMysql().

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::addColumn ( table_name,
column_name,
type = 'number',
size = '',
default = '',
notnull = false 
)

특정 테이블에 특정 column 추가

DBMysql.class.php 파일의 220 번째 라인에서 정의되었습니다.

다음을 참조함 : DB::$query, _query().

00220                                                                                                                {
00221             $type = $this->column_type[$type];
00222             if(strtoupper($type)=='INTEGER') $size = '';
00223 
00224             $query = sprintf("alter table %s%s add %s ", $this->prefix, $table_name, $column_name);
00225             if($size) $query .= sprintf(" %s(%s) ", $type, $size);
00226             else $query .= sprintf(" %s ", $type);
00227             if($default) $query .= sprintf(" default '%s' ", $default);
00228             if($notnull) $query .= " not null ";
00229 
00230             $this->_query($query);
00231         }

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

DBMysql::addIndex ( table_name,
index_name,
target_columns,
is_unique = false 
)

특정 테이블에 특정 인덱스 추가 $target_columns = array(col1, col2) $is_unique? unique : none

DBMysql.class.php 파일의 264 번째 라인에서 정의되었습니다.

다음을 참조함 : DB::$query, _query().

00264                                                                                          {
00265             if(!is_array($target_columns)) $target_columns = array($target_columns);
00266 
00267             $query = sprintf("alter table %s%s add %s index %s (%s);", $this->prefix, $table_name, $is_unique?'unique':'', $index_name, implode(',',$target_columns));
00268             $this->_query($query);
00269         }

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

DBMysql::addQuotes ( string  ) 

쿼리에서 입력되는 문자열 변수들의 quotation 조절

DBMysql.class.php 파일의 116 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : _createTable(), isTableExists(), isValidOldPassword().

00116                                     {
00117             if(version_compare(PHP_VERSION, "5.9.0", "<") && get_magic_quotes_gpc()) $string = stripslashes(str_replace("\\","\\\\",$string));
00118             if(!is_numeric($string)) $string = @mysql_escape_string($string);
00119             return $string;
00120         }

DBMysql::begin (  ) 

트랜잭션 시작

DBMysql.class.php 파일의 125 번째 라인에서 정의되었습니다.

00125                          {
00126         }

DBMysql::close (  ) 

DB접속 해제.

DBMysql.class.php 파일의 108 번째 라인에서 정의되었습니다.

다음을 참조함 : DB::isConnected().

00108                          {
00109             if(!$this->isConnected()) return;
00110             @mysql_close($this->fd);
00111         }

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

DBMysql::commit (  ) 

커밋

DBMysql.class.php 파일의 137 번째 라인에서 정의되었습니다.

00137                           {
00138         }

DBMysql::createTableByXml ( xml_doc  ) 

xml 을 받아서 테이블을 생성

DBMysql.class.php 파일의 301 번째 라인에서 정의되었습니다.

다음을 참조함 : _createTable().

00301                                             {
00302             return $this->_createTable($xml_doc);
00303         }

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

DBMysql::createTableByXmlFile ( file_name  ) 

xml 을 받아서 테이블을 생성

DBMysql.class.php 파일의 308 번째 라인에서 정의되었습니다.

다음을 참조함 : _createTable(), FileHandler::readFile().

00308                                                   {
00309             if(!file_exists($file_name)) return;
00310             // xml 파일을 읽음
00311             $buff = FileHandler::readFile($file_name);
00312             return $this->_createTable($buff);
00313         }

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

DBMysql::DBMysql (  ) 

constructor

DBMysql.class.php 파일의 42 번째 라인에서 정의되었습니다.

다음을 참조함 : _connect(), _setDBInfo().

00042                            {
00043             $this->_setDBInfo();
00044             $this->_connect();
00045         }

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

DBMysql::dropColumn ( table_name,
column_name 
)

특정 테이블에 특정 column 제거

DBMysql.class.php 파일의 236 번째 라인에서 정의되었습니다.

다음을 참조함 : DB::$query, _query().

00236                                                        {
00237             $query = sprintf("alter table %s%s drop %s ", $this->prefix, $table_name, $column_name);
00238             $this->_query($query);
00239         }

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

DBMysql::dropIndex ( table_name,
index_name,
is_unique = false 
)

특정 테이블의 특정 인덱스 삭제

DBMysql.class.php 파일의 274 번째 라인에서 정의되었습니다.

다음을 참조함 : DB::$query, _query().

00274                                                                          {
00275             $query = sprintf("alter table %s%s drop index %s;", $this->prefix, $table_name, $index_name);
00276             $this->_query($query);
00277         }

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

DBMysql::getCondition ( output  ) 

조건문 작성하여 return

DBMysql.class.php 파일의 385 번째 라인에서 정의되었습니다.

다음을 참조함 : $output, _getCondition().

다음에 의해서 참조됨 : _executeDeleteAct(), _executeSelectAct(), _executeUpdateAct().

00385                                        {
00386             if(!$output->conditions) return;
00387             $condition = $this->_getCondition($output->conditions,$output->column_type);
00388             if($condition) $condition = ' where '.$condition;
00389             return $condition;
00390         }

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

DBMysql::getLeftCondition ( conditions,
column_type 
)

DBMysql.class.php 파일의 392 번째 라인에서 정의되었습니다.

다음을 참조함 : $column_type, _getCondition().

00392                                                            {
00393             return $this->_getCondition($conditions,$column_type);
00394         }

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

DBMysql::getNextSequence (  ) 

1씩 증가되는 sequence값을 return (mysql의 auto_increment는 sequence테이블에서만 사용)

DBMysql.class.php 파일의 183 번째 라인에서 정의되었습니다.

다음을 참조함 : DB::$query, _query().

00183                                    {
00184             $query = sprintf("insert into `%ssequence` (seq) values ('0')", $this->prefix);
00185             $this->_query($query);
00186             $sequence = mysql_insert_id($this->fd);
00187             if($sequence % 10000 == 0) {
00188               $query = sprintf("delete from  `%ssequence` where seq < %d", $this->prefix, $sequence);
00189               $this->_query($query);
00190             }
00191 
00192             return $sequence;
00193         }

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

DBMysql::isColumnExists ( table_name,
column_name 
)

특정 테이블의 column의 정보를 return

DBMysql.class.php 파일의 244 번째 라인에서 정의되었습니다.

다음을 참조함 : $output, DB::$query, DB::$result, _fetch(), _query(), DB::isError().

00244                                                            {
00245             $query = sprintf("show fields from %s%s", $this->prefix, $table_name);
00246             $result = $this->_query($query);
00247             if($this->isError()) return;
00248             $output = $this->_fetch($result);
00249             if($output) {
00250                 $column_name = strtolower($column_name);
00251                 foreach($output as $key => $val) {
00252                     $name = strtolower($val->Field);
00253                     if($column_name == $name) return true;
00254                 }
00255             }
00256             return false;
00257         }

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

DBMysql::isIndexExists ( table_name,
index_name 
)

특정 테이블의 index 정보를 return

DBMysql.class.php 파일의 283 번째 라인에서 정의되었습니다.

다음을 참조함 : $output, DB::$query, DB::$result, _fetch(), _query(), DB::isError().

00283                                                          {
00284             //$query = sprintf("show indexes from %s%s where key_name = '%s' ", $this->prefix, $table_name, $index_name);
00285             $query = sprintf("show indexes from %s%s", $this->prefix, $table_name);
00286             $result = $this->_query($query);
00287             if($this->isError()) return;
00288             $output = $this->_fetch($result);
00289             if(!$output) return;
00290             if(!is_array($output)) $output = array($output);
00291 
00292             for($i=0;$i<count($output);$i++) {
00293                 if($output[$i]->Key_name == $index_name) return true;
00294             }
00295             return false;
00296         }

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

DBMysql::isSupported (  ) 

설치 가능 여부를 return

DBMysql.class.php 파일의 50 번째 라인에서 정의되었습니다.

00050                                {
00051             if(!function_exists('mysql_connect')) return false;
00052             return true;
00053         }

DBMysql::isTableExists ( target_name  ) 

테이블 기생성 여부 return

DBMysql.class.php 파일의 209 번째 라인에서 정의되었습니다.

다음을 참조함 : DB::$query, DB::$result, _fetch(), _query(), addQuotes().

다음에 의해서 참조됨 : _createTable().

00209                                              {
00210             $query = sprintf("show tables like '%s%s'", $this->prefix, $this->addQuotes($target_name));
00211             $result = $this->_query($query);
00212             $tmp = $this->_fetch($result);
00213             if(!$tmp) return false;
00214             return true;
00215         }

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

DBMysql::isValidOldPassword ( password,
saved_password 
)

mysql old password를 가져오는 함수 (mysql에서만 사용)

DBMysql.class.php 파일의 198 번째 라인에서 정의되었습니다.

다음을 참조함 : $password, DB::$query, DB::$result, _fetch(), _query(), addQuotes().

00198                                                                 {
00199             $query = sprintf("select password('%s') as password, old_password('%s') as old_password", $this->addQuotes($password), $this->addQuotes($password));
00200             $result = $this->_query($query);
00201             $tmp = $this->_fetch($result);
00202             if($tmp->password == $saved_password || $tmp->old_password == $saved_password) return true;
00203             return false;
00204         }

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

DBMysql::rollback (  ) 

롤백

DBMysql.class.php 파일의 131 번째 라인에서 정의되었습니다.

00131                             {
00132         }


멤버 데이타 문서화

DBMysql::$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.class.php 파일의 28 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : _getCondition(), getLeftCondition().

DBMysql::$database = NULL

database

DBMysql.class.php 파일의 19 번째 라인에서 정의되었습니다.

DBMysql::$hostname = '127.0.0.1'

Mysql DB에 접속하기 위한 정보.

hostname

DBMysql.class.php 파일의 16 번째 라인에서 정의되었습니다.

DBMysql::$password = NULL

password

DBMysql.class.php 파일의 18 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : isValidOldPassword().

DBMysql::$prefix = 'xe'

XE에서 사용할 테이블들의 prefix (한 DB에서 여러개의 XE 설치 가능).

DBMysql.class.php 파일의 20 번째 라인에서 정의되었습니다.

DBMysql::$userid = NULL

user id

DBMysql.class.php 파일의 17 번째 라인에서 정의되었습니다.


이 클래스에 대한 문서화 페이지는 다음의 파일로부터 생성되었습니다.:

생성시간 : Wed Oct 28 22:59:56 2009, 프로젝트명 : XpressEngine, 생성자 :   doxygen 1.6.1