You cannot see this page without javascript.

이 부분은 약간의 코어 소스 수정과 변수 선언을 해주셔야 합니다.

보통 개인 DB 건드리고 출력할 용도가 게시판, 위젯, 애드온 등이 되겠는데요.

이  팁에서는 게시판을 기준으로 설명하겠습니다.

준비물 : 팁, xml파일, func_include 애드온, class.php
사전지식 : func_include 애드온을 이용한 함수 사용법

class.php

class 클래스명 {
    function init(){
        Context::set('getTable',array('테이블명1','테이블명2'));
    }
   function getTable(){
        $output = executeQueryArray('board/skins/스킨명.테이블명', $obj);
        // 오류가 생기면 그냥 무시
        if(!$output->toBool()) return;
        return $output->data;
    }
}


테이블명.xml

<query id="테이블명" action="select">
    <tables>
        <table name="테이블명" /> <- 이곳 본인의 테이블명 적으시면 됩니다.
    </tables>
    <columns>
        <column name="*" />
    </columns>
</query>

게시판스킨 임의의 html 파일에 아래를 선언

<!--@if($func_check)-->
{@ func_include('modules/board/skins/스킨명/php/class.php') }
{@ 클래스명::init() }
{@ $tables = 클래스명::getTable() }
<!--@end-->

    <!--@foreach($tables as $key => $val)-->
         내용
    <!--@endforeach-->

core 파일 수정
classes/db/DBMysql_innodb.class.php <- 이것은 각 DB 종류에 따라 그 파일을 수정해야합니다.
      /**
         * @brief insertAct 처리
         **/
        function _executeInsertAct($output) {
            // 테이블 정리
            foreach($output->tables as $key => $val) {
                $prefix = (!@in_array($key, Context::get('getTable')))? $this->prefix:false;
                $table_list[] = '`'.$prefix.$val.'`';
            }
.... 중략

        /**
         * @brief updateAct 처리
         **/
        function _executeUpdateAct($output) {
            // 테이블 정리
            foreach($output->tables as $key => $val) {
                $prefix = (!@in_array($key, Context::get('getTable')))? $this->prefix:false;
                $table_list[] = '`'.$prefix.$val.'` as '.$key;
            }
....중략
        /**
         * @brief deleteAct 처리
         **/
        function _executeDeleteAct($output) {
            // 테이블 정리
            foreach($output->tables as $key => $val) {
                $prefix = (!@in_array($key, Context::get('getTable')))? $this->prefix:false;
                $table_list[] = '`'.$prefix.$val.'`';
            }
....중략
        /**
         * @brief selectAct 처리
         *
         * select의 경우 특정 페이지의 목록을 가져오는 것을 편하게 하기 위해n
         * navigation이라는 method를 제공
         **/
        function _executeSelectAct($output) {
            // 테이블 정리
            foreach($output->tables as $key => $val) {
                $prefix = (!@in_array($key, Context::get('getTable')))? $this->prefix:false;
                $table_list[] = '`'.$prefix.$val.'` as '.$key;
            }
....중략



$prefix 로 시작하는 것 하고 그 밑에 내용 두줄을 위와 같이 교체 해주세요.


원리는 위에 지정한 테이블명과 접근하려는 테이블명이 같을 경우 xe_ 등의 말머리를 출력하지 않게 하는 겁니다.
그렇게 때문에 본인의 DB에 xe_documents 라는 테이블과 documents 라는 테이블이 있을 경우 테이블명이 동일하기 때문에
이런 경우를 제외하고는 다 뽑는게 가능하다고 봅니다.
엮인글 :
List of Articles
번호 제목 글쓴이 날짜 조회 수sort

XE Login