예제 #1
0
if (!trim($it_id)) {
    alert("복사할 상품코드가 없습니다.");
}
$t_it_id = preg_replace("/[A-Za-z0-9\\-_]/", "", $new_it_id);
if ($t_it_id) {
    alert("상품코드는 영문자, 숫자, -, _ 만 사용할 수 있습니다.");
}
$row = sql_fetch(" select count(*) as cnt from {$g5['g5_shop_item_table']} where it_id = '{$new_it_id}' ");
if ($row['cnt']) {
    alert('이미 존재하는 상품코드 입니다.');
}
$sql = " select * from {$g5['g5_shop_item_table']} where it_id = '{$it_id}' limit 1 ";
$cp = sql_fetch($sql);
// 상품테이블의 필드가 추가되어도 수정하지 않도록 필드명을 추출하여 insert 퀴리를 생성한다. (상품코드만 새로운것으로 대체)
$sql_common = "";
$fields = sql_field_names($g5['g5_shop_item_table']);
foreach ($fields as $fld) {
    if ($fld == 'it_id' || $fld == 'it_sum_qty' || $fld == 'it_use_cnt' || $fld == 'it_use_avg' || $fld == 'it_use' || $fld == 'pt_comment' || $fld == 'pt_good' || $fld == 'pt_nogood' || $fld == 'pt_num' || $fld == 'pt_end' || $fld == 'pt_reserve' || $fld == 'pt_reserve_use' || $fld == 'it_time' || $fld == 'it_update_time') {
        continue;
    }
    $sql_common .= " , {$fld} = '" . addslashes($cp[$fld]) . "' ";
}
$sql_common .= " , it_time = '" . G5_TIME_YMDHIS . "' ";
$sql_common .= " , it_update_time = '" . G5_TIME_YMDHIS . "' ";
$sql_common .= " , pt_num = '" . G5_SERVER_TIME . "' ";
$sql = " insert {$g5['g5_shop_item_table']}\n\t\t\tset it_id = '{$new_it_id}'\n                {$sql_common} ";
sql_query($sql);
// 선택/추가 옵션 copy
$opt_sql = " insert ignore into {$g5['g5_shop_item_option_table']} ( io_id, io_type, it_id, io_price, io_stock_qty, io_noti_qty, io_use )\n                select io_id, io_type, '{$new_it_id}', io_price, io_stock_qty, io_noti_qty, io_use\n                    from {$g5['g5_shop_item_option_table']}\n                    where it_id = '{$it_id}'\n                    order by io_no asc ";
sql_query($opt_sql);
// html 에디터로 첨부된 이미지 파일 복사
예제 #2
0
            // 첨부파일개수
            $wr_id = $row3['wr_id'];
            $sql4 = " select count(*) as cnt from {$g4['board_file_table']} where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' ";
            $row4 = sql_fetch($sql4);
            $sql_common3 .= " , wr_file = '{$row4['cnt']}' ";
            sql_query(" INSERT INTO {$create_table} SET {$sql_common3} ");
        }
        echo '<li>' . str_replace(G5_TABLE_PREFIX . 'write_', '', $create_table) . ' 게시글 복사</li>';
    }
}
unset($columns);
unset($fiels);
// 그외 테이블 복사
$tables = array('board_file', 'board_new', 'board_good', 'mail', 'memo', 'group_member', 'auth', 'popular', 'poll', 'poll_etc', 'scrap');
foreach ($tables as $table) {
    $columns = sql_field_names($g5[$table . '_table']);
    $src_table = $g4[$table . '_table'];
    $dst_table = $g5[$table . '_table'];
    $sql = " select * from {$src_table} ";
    $result = sql_query($sql);
    for ($i = 0; $row = sql_fetch_array($result); $i++) {
        if ($is_euckr) {
            $row = array_map('iconv_utf8', $row);
        }
        $comma = '';
        $sql_common = '';
        foreach ($row as $key => $val) {
            if (!in_array($key, $columns)) {
                continue;
            }
            $sql_common .= $comma . " {$key} = '" . addslashes($val) . "' ";