DBPostgresql 클래스 참조

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

모든 멤버 목록

Public 멤버 함수

 DBPostgresql ()
 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 (postgresql의 auto_increment는 sequence테이블에서만 사용)
 isTableExists ($target_name)
 테이블 기생성 여부 return
 addColumn ($table_name, $column_name, $type= 'number', $size= '', $default=NULL, $notnull=false)
 특정 테이블에 특정 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
 dropColumn ($table_name, $column_name)
 특정 테이블에 특정 column 제거
 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'
 PostgreSQL DB에 접속하기 위한 정보.
 $userid = null
 user id
 $password = null
 password
 $database = null
 database
 $prefix = 'xe'
 XE에서 사용할 테이블들의 prefix (한 DB에서 여러개의 XE설치 가능).
 $column_type
 postgresql에서 사용될 column type

상세한 설명

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


멤버 함수 문서화

DBPostgresql::_connect (  ) 

DB 접속.

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

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

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

00083     {
00084         // pg용 connection string
00085         $conn_string = "";
00086 
00087         // db 정보가 없으면 무시
00088         if (!$this->hostname || !$this->userid || !$this->database)
00089             return;
00090 
00091         // connection string 만들기
00092         $conn_string .= ($this->hostname) ? " host=$this->hostname" : "";
00093         $conn_string .= ($this->userid) ? " user=$this->userid" : "";
00094         $conn_string .= ($this->password) ? " password=$this->password" : "";
00095         $conn_string .= ($this->database) ? " dbname=$this->database" : "";
00096         $conn_string .= ($this->port) ? " port=$this->port" : "";
00097 
00098         // 접속시도
00099         $this->fd = @pg_connect($conn_string);
00100         if (!$this->fd || pg_connection_status($this->fd) != PGSQL_CONNECTION_OK) {
00101             $this->setError(-1, "CONNECTION FAILURE");
00102             return;
00103         }
00104 
00105         // 접속체크
00106         $this->is_connected = true;
00107 
00108         // utf8임을 지정
00109         //$this ->_query('set client_encoding to uhc');
00110     }

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

DBPostgresql::_createTable ( xml_doc  ) 

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

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

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

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

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

00423     {
00424         // xml parsing
00425         $oXml = new XmlParser();
00426         $xml_obj = $oXml->parse($xml_doc);
00427 
00428         // 테이블 생성 schema 작성
00429         $table_name = $xml_obj->table->attrs->name;
00430 
00431         if ($table_name == 'sequence') {
00432             $query = sprintf('create sequence %s', $this->prefix . $table_name);
00433             return $this->_query($query);
00434         }
00435 
00436         if ($this->isTableExists($table_name))
00437             return;
00438         $table_name = $this->prefix . $table_name;
00439 
00440         if (!is_array($xml_obj->table->column))
00441             $columns[] = $xml_obj->table->column;
00442         else
00443             $columns = $xml_obj->table->column;
00444 
00445         foreach ($columns as $column) {
00446             $name = $column->attrs->name;
00447             $type = $column->attrs->type;
00448             $size = $column->attrs->size;
00449             $notnull = $column->attrs->notnull;
00450             $primary_key = $column->attrs->primary_key;
00451             $index = $column->attrs->index;
00452             $unique = $column->attrs->unique;
00453             $default = $column->attrs->default;
00454             $auto_increment = $column->attrs->auto_increment;
00455 
00456             if ($type == "bignumber" || $type == "number")
00457                 $size = 0;
00458 
00459             $column_schema[] = sprintf('%s %s%s %s %s', $name, $this->column_type[$type], $size ?
00460                 '(' . $size . ')' : '', $default ? "default '" . $default . "'" : '', $notnull ?
00461                 'not null' : '');
00462 
00463             if ($primary_key)
00464                 $primary_list[] = $name;
00465             else
00466                 if ($unique)
00467                     $unique_list[$unique][] = $name;
00468                 else
00469                     if ($index)
00470                         $index_list[$index][] = $name;
00471         }
00472 
00473         if (count($primary_list)) {
00474             $column_schema[] = sprintf("primary key (%s)", implode($primary_list, ','));
00475         }
00476 
00477         if (count($unique_list)) {
00478             foreach ($unique_list as $key => $val) {
00479                 $column_schema[] = sprintf("unique (%s)", implode($val, ','));
00480             }
00481         }
00482 
00483 
00484         $schema = sprintf('create table %s (%s%s);', $this->addQuotes($table_name), "\n",
00485             implode($column_schema, ",\n"));
00486 
00487         $output = $this->_query($schema);
00488 
00489         if (count($index_list)) {
00490             foreach ($index_list as $key => $val) {
00491                 if (!$this->isIndexExists($table_name, $key))
00492                     $this->addIndex($table_name, $key, $val);
00493             }
00494         }
00495 
00496         if (!$output)
00497             return false;
00498 
00499     }

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

DBPostgresql::_executeDeleteAct ( output  ) 

deleteAct 처리

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

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

00629     {
00630         // 테이블 정리
00631         foreach ($output->tables as $key => $val) {
00632             $table_list[] = $this->prefix . $val;
00633         }
00634 
00635         // 조건절 정리
00636         $condition = $this->getCondition($output);
00637 
00638         $query = sprintf("delete from %s %s", implode(',', $table_list), $condition);
00639 
00640         return $this->_query($query);
00641     }

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

DBPostgresql::_executeInsertAct ( output  ) 

insertAct 처리

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

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

00561     {
00562         // 테이블 정리
00563         foreach ($output->tables as $key => $val) {
00564             $table_list[] = $this->prefix . $val;
00565         }
00566 
00567         // 컬럼 정리
00568         foreach ($output->columns as $key => $val) {
00569             $name = $val['name'];
00570             $value = $val['value'];
00571             if ($output->column_type[$name] != 'number') {
00572                 $value = "'" . $this->addQuotes($value) . "'";
00573                 if (!$value)
00574                     $value = 'null';
00575             } elseif (!$value || is_numeric($value))
00576                 $value = (int)$value;
00577 
00578             $column_list[] = $name;
00579             $value_list[] = $value;
00580         }
00581 
00582         $query = sprintf("insert into %s (%s) values (%s);", implode(',', $table_list),
00583             implode(',', $column_list), implode(',', $value_list));
00584         return $this->_query($query);
00585     }

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

DBPostgresql::_executeSelectAct ( output  ) 

selectAct 처리

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

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

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

00650     {
00651         // 테이블 정리
00652         $table_list = array();
00653         foreach ($output->tables as $key => $val) {
00654             $table_list[] = $this->prefix . $val . ' as ' . $key;
00655         }
00656 
00657         $left_join = array();
00658         // why???
00659         $left_tables = (array )$output->left_tables;
00660 
00661         foreach ($left_tables as $key => $val) {
00662             $condition = $this->_getCondition($output->left_conditions[$key], $output->
00663                 column_type);
00664             if ($condition) {
00665                 $left_join[] = $val . ' ' . $this->prefix . $output->_tables[$key] . ' as ' . $key .
00666                     ' on (' . $condition . ')';
00667             }
00668         }
00669 
00670 
00671         if (!$output->columns) {
00672             $columns = '*';
00673         } else {
00674             $column_list = array();
00675             foreach ($output->columns as $key => $val) {
00676                 $name = $val['name'];
00677                 $alias = $val['alias'];
00678                 if($val['click_count']) $click_count[] = $val['name'];
00679 
00680                 if (substr($name, -1) == '*') {
00681                     $column_list[] = $name;
00682                 } elseif (strpos($name, '.') === false && strpos($name, '(') === false) {
00683                     if ($alias)
00684                         $column_list[] = sprintf('%s as %s', $name, $alias);
00685                     else
00686                         $column_list[] = sprintf('%s', $name);
00687                 } else {
00688                     if ($alias)
00689                         $column_list[] = sprintf('%s as %s', $name, $alias);
00690                     else
00691                         $column_list[] = sprintf('%s', $name);
00692                 }
00693             }
00694             $columns = implode(',', $column_list);
00695         }
00696 
00697         $condition = $this->getCondition($output);
00698 
00699         if ($output->list_count && $output->page)
00700             return $this->_getNavigationData($table_list, $columns, $left_join, $condition,
00701                 $output);
00702 
00703         // list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가
00704         if ($output->order) {
00705             $conditions = $this->getConditionList($output);
00706             if (!in_array('list_order', $conditions) && !in_array('update_order', $conditions)) {
00707                 foreach ($output->order as $key => $val) {
00708                     $col = $val[0];
00709                     if (!in_array($col, array('list_order', 'update_order')))
00710                         continue;
00711                     if ($condition)
00712                         $condition .= sprintf(' and %s < 2100000000 ', $col);
00713                     else
00714                         $condition = sprintf(' where %s < 2100000000 ', $col);
00715                 }
00716             }
00717         }
00718 
00719         $query = sprintf("select %s from %s %s %s", $columns, implode(',', $table_list),
00720             implode(' ', $left_join), $condition);
00721 
00722         if (count($output->groups)) {
00723             /*
00724             var_dump("= column output start = ");
00725             var_dump(sizeof ($output->columns) . " = end length == ");
00726             var_dump($output->columns);
00727             var_dump("= column output end = " . "\n");
00728             var_dump($output->groups);
00729             var_dump("=== " . "\n");
00730             var_dump(debug_backtrace());
00731             
00732             foreach($output->columns as $key => $val) {
00733             $name = $val['name'];
00734             $alias = $val['alias'];
00735             } */
00736             $group_list = array();
00737             foreach ($output->groups as $gkey => $gval) {
00738                 foreach ($output->columns as $key => $val) {
00739                     $name = $val['name'];
00740                     $alias = $val['alias'];
00741                     if (trim($name) == trim($gval)) {
00742                         $group_list[] = $alias;
00743                         break;
00744                     }
00745                 }
00746 
00747             }
00748             $query .= sprintf(' group by %s', implode(',', $group_list));
00749             //             var_dump($query);
00750         }
00751 
00752         if ($output->order) {
00753             foreach ($output->order as $key => $val) {
00754                 $index_list[] = sprintf('%s %s', $val[0], $val[1]);
00755             }
00756             if (count($index_list))
00757                 $query .= ' order by ' . implode(',', $index_list);
00758         }
00759 
00760         $result = $this->_query($query);
00761         if ($this->isError())
00762             return;
00763         
00764         if(count($click_count)>0 && count($output->conditions)>0){
00765             $_query = '';
00766             foreach($click_count as $k => $c) $_query .= sprintf(',%s=%s+1 ',$c,$c);
00767             $_query = sprintf('update %s set %s %s',implode(',',$table_list), substr($_query,1),  $condition);
00768             $this->_query($_query);
00769         }
00770 
00771 
00772         $data = $this->_fetch($result);
00773 
00774         $buff = new Object();
00775         $buff->data = $data;
00776         return $buff;
00777     }

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

DBPostgresql::_executeUpdateAct ( output  ) 

updateAct 처리

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

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

00591     {
00592         // 테이블 정리
00593         foreach ($output->tables as $key => $val) {
00594             //$table_list[] = $this->prefix.$val.' as '.$key;
00595             $table_list[] = $this->prefix . $val;
00596         }
00597 
00598         // 컬럼 정리
00599         foreach ($output->columns as $key => $val) {
00600             if (!isset($val['value']))
00601                 continue;
00602             $name = $val['name'];
00603             $value = $val['value'];
00604             if (strpos($name, '.') !== false && strpos($value, '.') !== false)
00605                 $column_list[] = $name . ' = ' . $value;
00606             else {
00607                 if ($output->column_type[$name] != 'number')
00608                     $value = "'" . $this->addQuotes($value) . "'";
00609                 elseif (!$value || is_numeric($value))
00610                     $value = (int)$value;
00611 
00612                 $column_list[] = sprintf("%s = %s", $name, $value);
00613             }
00614         }
00615 
00616         // 조건절 정리
00617         $condition = $this->getCondition($output);
00618 
00619         $query = sprintf("update %s set %s %s", implode(',', $table_list), implode(',',
00620             $column_list), $condition);
00621 
00622         return $this->_query($query);
00623     }

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

DBPostgresql::_fetch ( result  ) 

결과를 fetch

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

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

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

00231     {
00232         if (!$this->isConnected() || $this->isError() || !$result)
00233             return;
00234         while ($tmp = pg_fetch_object($result)) {
00235             $output[] = $tmp;
00236         }
00237         if (count($output) == 1)
00238             return $output[0];
00239         return $output;
00240     }

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

DBPostgresql::_getCondition ( conditions,
column_type 
)

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

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

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

00521     {
00522         $condition = '';
00523         foreach ($conditions as $val) {
00524             $sub_condition = '';
00525             foreach ($val['condition'] as $v) {
00526                 if (!isset($v['value']))
00527                     continue;
00528                 if ($v['value'] === '')
00529                     continue;
00530                 if (!in_array(gettype($v['value']), array('string', 'integer')))
00531                     continue;
00532 
00533                 $name = $v['column'];
00534                 $operation = $v['operation'];
00535                 $value = $v['value'];
00536                 $type = $this->getColumnType($column_type, $name);
00537                 $pipe = $v['pipe'];
00538 
00539                 $value = $this->getConditionValue($name, $value, $operation, $type, $column_type);
00540                 if (!$value)
00541                     $value = $v['value'];
00542                 $str = $this->getConditionPart($name, $value, $operation);
00543                 if ($sub_condition)
00544                     $sub_condition .= ' ' . $pipe . ' ';
00545                 $sub_condition .= $str;
00546             }
00547             if ($sub_condition) {
00548                 if ($condition && $val['pipe'])
00549                     $condition .= ' ' . $val['pipe'] . ' ';
00550                 $condition .= '(' . $sub_condition . ')';
00551             }
00552         }
00553         return $condition;
00554     }

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

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

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

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

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

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

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

00785     {
00786         require_once (_XE_PATH_ . 'classes/page/PageHandler.class.php');
00787 
00788         /*
00789         // group by 절이 포함된 SELECT 쿼리의 전체 갯수를 구하기 위한 수정
00790         // 정상적인 동작이 확인되면 주석으로 막아둔 부분으로 대체합니다.
00791         //
00792         $count_condition = count($output->groups) ? sprintf('%s group by %s', $condition, implode(', ', $output->groups)) : $condition;
00793         $total_count = $this->getCountCache($output->tables, $count_condition);
00794         if ($total_count === false) {
00795             $count_query = sprintf('select count(*) as count from %s %s %s', implode(', ', $table_list), implode(' ', $left_join), $count_condition);
00796             if (count($output->groups))
00797                 $count_query = sprintf('select count(*) as count from (%s) xet', $count_query);
00798             $result = $this->_query($count_query);
00799             $count_output = $this->_fetch($result);
00800             $total_count = (int)$count_output->count;
00801             $this->putCountCache($output->tables, $count_condition, $total_count);
00802         }
00803         */
00804 
00805         // 전체 개수를 구함
00806         $count_query = sprintf("select count(*) as count from %s %s %s", implode(',', $table_list),
00807             implode(' ', $left_join), $condition);
00808         $total_count = $this->getCountCache($output->tables, $condition);
00809         if ($total_count === false) {
00810             $result = $this->_query($count_query);
00811             $count_output = $this->_fetch($result);
00812             $total_count = (int)$count_output->count;
00813             $this->putCountCache($output->tables, $condition, $total_count);
00814         }
00815 
00816         $list_count = $output->list_count['value'];
00817         if (!$list_count)
00818             $list_count = 20;
00819         $page_count = $output->page_count['value'];
00820         if (!$page_count)
00821             $page_count = 10;
00822         $page = $output->page['value'];
00823         if (!$page)
00824             $page = 1;
00825 
00826         // 전체 페이지를 구함
00827         if ($total_count)
00828             $total_page = (int)(($total_count - 1) / $list_count) + 1;
00829         else
00830             $total_page = 1;
00831 
00832         // 페이지 변수를 체크
00833         if ($page > $total_page)
00834             $page = $total_page;
00835         $start_count = ($page - 1) * $list_count;
00836 
00837         // list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가
00838         if ($output->order) {
00839             $conditions = $this->getConditionList($output);
00840             if (!in_array('list_order', $conditions) && !in_array('update_order', $conditions)) {
00841                 foreach ($output->order as $key => $val) {
00842                     $col = $val[0];
00843                     if (!in_array($col, array('list_order', 'update_order')))
00844                         continue;
00845                     if ($condition)
00846                         $condition .= sprintf(' and %s < 2100000000 ', $col);
00847                     else
00848                         $condition = sprintf(' where %s < 2100000000 ', $col);
00849                 }
00850             }
00851         }
00852 
00853         $query = sprintf("select %s from %s %s %s", $columns, implode(',', $table_list),
00854             implode(' ', $left_join), $condition);
00855 
00856         if (count($output->groups))
00857             $query .= sprintf(' group by %s', implode(',', $output->groups));
00858 
00859         if (count($output->order)) {
00860             foreach ($output->order as $key => $val) {
00861                 $index_list[] = sprintf('%s %s', $val[0], $val[1]);
00862             }
00863             if (count($index_list))
00864                 $query .= ' order by ' . implode(',', $index_list);
00865         }
00866 
00867         $query = sprintf('%s offset %d limit %d', $query, $start_count, $list_count);
00868 
00869         $result = $this->_query($query);
00870         if ($this->isError()) {
00871             $buff = new Object();
00872             $buff->total_count = 0;
00873             $buff->total_page = 0;
00874             $buff->page = 1;
00875             $buff->data = array();
00876 
00877             $buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count);
00878             return $buff;
00879         }
00880 
00881         $virtual_no = $total_count - ($page - 1) * $list_count;
00882         while ($tmp = pg_fetch_object($result)) {
00883             $data[$virtual_no--] = $tmp;
00884         }
00885 
00886         $buff = new Object();
00887         $buff->total_count = $total_count;
00888         $buff->total_page = $total_page;
00889         $buff->page = $page;
00890         $buff->data = $data;
00891 
00892         $buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count);
00893         return $buff;
00894     }

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

DBPostgresql::_query ( query  ) 

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

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

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

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

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

00177     {
00178         if (!$this->isConnected())
00179             return;
00180 
00181         /*
00182         $l_query_array = explode(" ", $query);
00183         if ($l_query_array[0] = "update")
00184         {
00185         if (strtolower($l_query_array[2]) == "as")
00186         {
00187         $l_query_array[2] = "";
00188         $l_query_array[3] = "";
00189         $query = implode(" ",$l_query_array);
00190         }
00191         }
00192         else if ($l_query_array[0] = "delete") 
00193         {
00194         if (strtolower($l_query_array[3]) == "as")
00195         {
00196         $l_query_array[3] = "";
00197         $l_query_array[4] = "";            
00198         $query = implode(" ",$l_query_array);
00199         }
00200         }
00201         */
00202 
00203         // 쿼리 시작을 알림
00204         $this->actStart($query);
00205         $arr = array('Hello', 'World!', 'Beautiful', 'Day!');
00206 
00207 
00208         // 쿼리 문 실행
00209         $result = @pg_query($this->fd, $query);
00210 
00211         // 오류 체크
00212         if (!$result) {
00213             //              var_dump($l_query_array);
00214             //var_dump($query);
00215             //die("\nin query statement\n");
00216             //var_dump(debug_backtrace());
00217             $this->setError(1, pg_last_error($this->fd));
00218         }
00219 
00220         // 쿼리 실행 종료를 알림
00221         $this->actFinish();
00222 
00223         // 결과 리턴
00224         return $result;
00225     }

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

DBPostgresql::_setDBInfo (  ) 

DB정보 설정 및 connect/ close.

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

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

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

00067     {
00068         $db_info = Context::getDBInfo();
00069         $this->hostname = $db_info->db_hostname;
00070         $this->port = $db_info->db_port;
00071         $this->userid = $db_info->db_userid;
00072         $this->password = $db_info->db_password;
00073         $this->database = $db_info->db_database;
00074         $this->prefix = $db_info->db_table_prefix;
00075         if (!substr($this->prefix, -1) != '_')
00076             $this->prefix .= '_';
00077     }

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

DBPostgresql::addColumn ( table_name,
column_name,
type = 'number',
size = '',
default = NULL,
notnull = false 
)

특정 테이블에 특정 column 추가

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

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

00275     {
00276         $type = $this->column_type[$type];
00277         if (strtoupper($type) == 'INTEGER' || strtoupper($type) == 'BIGINT')
00278             $size = '';
00279 
00280         $query = sprintf("alter table %s%s add %s ", $this->prefix, $table_name, $column_name);
00281 
00282         if ($size)
00283             $query .= sprintf(" %s(%s) ", $type, $size);
00284         else
00285             $query .= sprintf(" %s ", $type);
00286 
00287         $this->_query($query);
00288 
00289         if (isset($default)) {
00290             $query = sprintf("alter table %s%s alter %s  set default '%s' ", $this->prefix, $table_name, $column_name, $default);
00291             $this->_query($query);
00292         }
00293         if ($notnull) {
00294             $query = sprintf("update %s%s set %s  = %s ", $this->prefix, $table_name, $column_name, $default);
00295             $this->_query($query);              
00296             $query = sprintf("alter table %s%s alter %s  set not null ", $this->prefix, $table_name, $column_name);
00297             $this->_query($query);
00298         }
00299     }

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

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

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

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

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

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

00328     {
00329         if (!is_array($target_columns))
00330             $target_columns = array($target_columns);
00331 
00332         if (strpos($table_name, $this->prefix) === false)
00333             $table_name = $this->prefix . $table_name;
00334 
00335         // index_name의 경우 앞에 table이름을 붙여줘서 중복을 피함
00336         $index_name = $table_name . $index_name;
00337 
00338         $query = sprintf("create %s index %s on %s (%s);", $is_unique ? 'unique' : '', $index_name,
00339             $table_name, implode(',', $target_columns));
00340         $this->_query($query);
00341     }

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

DBPostgresql::addQuotes ( string  ) 

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

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

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

00126     {
00127         if (version_compare(PHP_VERSION, "5.9.0", "<") && get_magic_quotes_gpc())
00128             $string = stripslashes(str_replace("\\", "\\\\", $string));
00129         if (!is_numeric($string))
00130             $string = @pg_escape_string($string);
00131         return $string;
00132     }

DBPostgresql::begin (  ) 

트랜잭션 시작

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

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

00138     {
00139         if (!$this->isConnected() || $this->transaction_started == false)
00140             return;
00141         if ($this->_query($this->fd, 'BEGIN'))
00142             $this->transaction_started = true;
00143     }

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

DBPostgresql::close (  ) 

DB접속 해제.

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

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

00116     {
00117         if (!$this->isConnected())
00118             return;
00119         @pg_close($this->fd);
00120     }

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

DBPostgresql::commit (  ) 

커밋

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

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

00160     {
00161         if (!$this->isConnected() || $this->transaction_started == false)
00162             return;
00163         if ($this->_query($this->fd, 'COMMIT'))
00164             $this->transaction_started = false;
00165     }

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

DBPostgresql::createTableByXml ( xml_doc  ) 

xml 을 받아서 테이블을 생성

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

다음을 참조함 : _createTable().

00399     {
00400         return $this->_createTable($xml_doc);
00401     }

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

DBPostgresql::createTableByXmlFile ( file_name  ) 

xml 을 받아서 테이블을 생성

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

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

00407     {
00408         if (!file_exists($file_name))
00409             return;
00410         // xml 파일을 읽음
00411         $buff = FileHandler::readFile($file_name);
00412         return $this->_createTable($buff);
00413     }

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

DBPostgresql::DBPostgresql (  ) 

constructor

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

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

00048     {
00049         $this->_setDBInfo();
00050         $this->_connect();
00051     }

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

DBPostgresql::dropColumn ( table_name,
column_name 
)

특정 테이블에 특정 column 제거

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

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

00347     {
00348         $query = sprintf("alter table %s%s drop %s ", $this->prefix, $table_name, $column_name);
00349         $this->_query($query);
00350     }

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

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

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

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

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

00356     {
00357         if (strpos($table_name, $this->prefix) === false)
00358             $table_name = $this->prefix . $table_name;
00359 
00360         // index_name의 경우 앞에 table이름을 붙여줘서 중복을 피함
00361         $index_name = $table_name . $index_name;
00362 
00363         $query = sprintf("drop index %s", $index_name);
00364         $this->_query($query);
00365     }

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

DBPostgresql::getCondition ( output  ) 

조건문 작성하여 return

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

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

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

00505     {
00506         if (!$output->conditions)
00507             return;
00508         $condition = $this->_getCondition($output->conditions, $output->column_type);
00509         if ($condition)
00510             $condition = ' where ' . $condition;
00511         return $condition;
00512     }

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

DBPostgresql::getLeftCondition ( conditions,
column_type 
)

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

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

00515     {
00516         return $this->_getCondition($conditions, $column_type);
00517     }

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

DBPostgresql::getNextSequence (  ) 

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

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

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

00246     {
00247         $query = sprintf("select nextval('%ssequence') as seq", $this->prefix);
00248         $result = $this->_query($query);
00249         $tmp = $this->_fetch($result);
00250         return $tmp->seq;
00251     }

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

DBPostgresql::isColumnExists ( table_name,
column_name 
)

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

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

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

00306     {
00307         $query = sprintf("SELECT attname FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = '%s%s') AND attname = '%s'",
00308             $this->prefix, strtolower($table_name), strtolower($column_name));
00309 
00310         // $query = sprintf("select column_name from information_schema.columns where table_schema = current_schema() and table_name = '%s%s' and column_name = '%s'", $this->prefix, $this->addQuotes($table_name), strtolower($column_name));
00311         $result = $this->_query($query);
00312         if ($this->isError()) {
00313             return;
00314         }
00315         $output = $this->_fetch($result);
00316         if ($output) {
00317             return true;
00318         }
00319         return false;
00320     }

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

DBPostgresql::isIndexExists ( table_name,
index_name 
)

특정 테이블의 index 정보를 return

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

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

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

00372     {
00373         if (strpos($table_name, $this->prefix) === false)
00374             $table_name = $this->prefix . $table_name;
00375 
00376         // index_name의 경우 앞에 table이름을 붙여줘서 중복을 피함
00377         $index_name = $table_name . $index_name;
00378 
00379         //$query = sprintf("show indexes from %s%s where key_name = '%s' ", $this->prefix, $table_name, $index_name);
00380         $query = sprintf("select indexname from pg_indexes where schemaname = current_schema() and tablename = '%s' and indexname = '%s'",
00381             $table_name, strtolower($index_name));
00382         $result = $this->_query($query);
00383         if ($this->isError())
00384             return;
00385         $output = $this->_fetch($result);
00386 
00387         if ($output) {
00388             return true;
00389         }
00390         //                var_dump($query);
00391         //                die(" no index");
00392         return false;
00393     }

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

DBPostgresql::isSupported (  ) 

설치 가능 여부를 return

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

00057     {
00058         if (!function_exists('pg_connect'))
00059             return false;
00060         return true;
00061     }

DBPostgresql::isTableExists ( target_name  ) 

테이블 기생성 여부 return

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

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

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

00257     {
00258         if ($target_name == "sequence")
00259             return true;
00260         $query = sprintf("SELECT tablename FROM pg_tables WHERE tablename = '%s%s' AND schemaname = current_schema()",
00261             $this->prefix, $this->addQuotes($target_name));
00262 
00263         $result = $this->_query($query);
00264         $tmp = $this->_fetch($result);
00265         if (!$tmp)
00266             return false;
00267         return true;
00268     }

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

DBPostgresql::rollback (  ) 

롤백

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

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

00149     {
00150         if (!$this->isConnected() || $this->transaction_started == false)
00151             return;
00152         if ($this->_query($this->fd, 'ROLLBACK'))
00153             $this->transaction_started = false;
00154     }

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


멤버 데이타 문서화

DBPostgresql::$column_type
초기값:
 array(
        'bignumber' => 'bigint', 
        'number' => 'integer',
        'varchar' => 'varchar', 
        'char' => 'char', 
        'text' => 'text', 
        'bigtext' => 'text',
        'date' => 'varchar(14)', 
        'float' => 'real',
    )

postgresql에서 사용될 column type

column_type은 schema/query xml에서 공통 선언된 type을 이용하기 때문에 각 DBMS에 맞게 replace 해주어야 한다

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

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

DBPostgresql::$database = null

database

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

DBPostgresql::$hostname = '127.0.0.1'

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

hostname

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

DBPostgresql::$password = null

password

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

DBPostgresql::$prefix = 'xe'

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

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

DBPostgresql::$userid = null

user id

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


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

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