Giter Club home page Giter Club logo

Comments (3)

thisgun avatar thisgun commented on August 15, 2024 1

hook 을 이용해서 아래와 같이 데이터베이스 필드를 수정 할수 있습니다.

글쓰기전에 동작

add_event('write_update_before', 'fn_write_update_before', 0, 1);

function fn_write_update_before($board){
    global $g5;

    $write_table = $g5['write_prefix'].$board['bo_table'];

    $sql = " SHOW COLUMNS FROM `{$write_table}` LIKE 'wr_option' ";
    $row = sql_fetch($sql);
    
    $sql_sets = $change_sets = explode(",", str_replace(array("set(", ")", "'"), "", $row['Type']));

    if( ! in_array('text', $sql_sets) ){
        $change_sets[] = 'text';
    }

    if( ! in_array('markdown_text', $sql_sets) ){
        $change_sets[] = 'markdown_text';
    }

    if( $sql_sets !== $change_sets ){
        $sql = " ALTER TABLE `{$write_table}` CHANGE `wr_option` `wr_option` set('".implode("','", $change_sets)."') NOT NULL DEFAULT '' ";

        sql_query($sql, false);
    }

}

관리자에서 DB 업그레이드 동작

add_replace('admin_dbupgrade', 'fn_admin_dbupgrade_ne', 0, 1);

function fn_admin_dbupgrade_ne($is_check){
    global $g5;

    $result = sql_query(" select bo_table from `{$g5['board_table']}` ");
    for ($i=0; $row=sql_fetch_array($result); $i++) {
        
        $write_table = $g5['write_prefix'].$row['bo_table'];

        $sql = " SHOW COLUMNS FROM `{$write_table}` LIKE 'wr_option' ";
        $row = sql_fetch($sql);
        
        $sql_sets = $change_sets = explode(",", str_replace(array("set(", ")", "'"), "", $row['Type']));

        if( ! in_array('text', $sql_sets) ){
            $change_sets[] = 'text';
        }

        if( ! in_array('markdown_text', $sql_sets) ){
            $change_sets[] = 'markdown_text';
        }

        if( $sql_sets !== $change_sets ){
            $sql = " ALTER TABLE `{$write_table}` CHANGE `wr_option` `wr_option` set('".implode("','", $change_sets)."') NOT NULL DEFAULT '' ";
            
            sql_query($sql, false);

            $is_check = true;
        }

    }

    return $is_check;
}

from gnuboard5.

woosungchoi avatar woosungchoi commented on August 15, 2024

미래를 위해... 응원합니다.

from gnuboard5.

jakekwak avatar jakekwak commented on August 15, 2024

@thisgun 감사합니다.

from gnuboard5.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.