I want to move data fromt test_dba to test_dbb.
I am working on xp, and will upload this file to linux box - fedora 3.
On xp, this file shows some problems.
- "Duplicate entry for key 1" came back.
- Files are not fully copied.
the source file link is here.
<?
include_once("./_common.php");
include_once 'dbconn.php';
$sql = " select * from test_dba_board_{$src} order by headnum ,arrangenum ";
$test_dba_result = mysql_query($sql);
?>
<?
$tmp_target = $test_dbb[write_prefix] . $dst;
@mkdir("$test_dbb[dir]/data/file/$dst", 0707);
@chmod("$test_dbb[dir]/data/file/$dst", 0707);
mysql_select_db($test_dbb[db], $test_dba[conn]) or die("$test_dbb[db] ??.");
mysql_query(" delete from test_dbb_board_file where bo_table = '$dst' ") or die(mysql_error());
$sql_test_dbbgb="TRUNCATE TABLE test_dbb_write_{$dst}";
mysql_query($sql_test_dbbgb) or die(mysql_error());
$cnt = 0;
$count_write = 0;
$count_comment = 0;
$save_num = null;
while ($row=mysql_fetch_array($test_dba_result))
{
$id = mysql_insert_id();
if ($save_num == $num) {
$parent_id = $save_id;
} else {
$parent_id = $id;
$save_id = $id;
}
mysql_query(" update test_dbb_write_{$dst} set wr_parent_id = '$save_id' where wr_id = '$id' ");
mysql_query("update test_dbb_board set bo_total_count = bo_total_count + 1 where bo_table = '$dst'");
$file1 = "";
$file1_source = "";
$bf_no = +1;
if ($row[file_name1]) {
//file copy
$file1 = substr(md5($i),0,8) . "_" . $row[s_file_name1];
$file1_source = $row[s_file_name1];
if (copy("$test_dba[dir]/$row[file_name1]", "$test_dbb[dir]/data/file/$dst/$file1")) {
print ("copied *$test_dbb[dir]/data/file/$dst/$file1"); } else { print ("failed copy $test_dbb[dir]/data/file/$dst/$file1");
}
@chmod("$test_dbb[dir]/data/file/$dst/$file1", 0606);
$bf_file1 = addslashes($file1);
$bf_source1 = addslashes($row[s_file_name1]);
$sql_fc1 = " insert into test_dbb_board_file set bo_table = '$dst', wr_id = '$id', bf_no = '$bf_no', bf_source = '$bf_source1', bf_file = '$bf_file1', bf_download = '$row[download1]' ";
mysql_query($sql_fc1) or die(mysql_error());
$bf_no++;
}
if ($row[file_name2]) {
$file2 = substr(md5($i),0,8) . "_" . $row[s_file_name2];
$file2_source = $row[s_file_name2];
if (copy("$test_dba[dir]/$row[file_name2]", "$test_dbb[dir]/data/file/$dst/$file2")) {
print ("copied [$test_dbb[dir]/data/file/$dst/$file2]"); } else { print ("failed copy [$test_dbb[dir]/data/file/$dst/$file2]");
}
@chmod("$test_dbb[dir]/data/file/$dst/$s_file_name2", 0606);
$bf_file2 = addslashes($file2);
$bf_source2 = addslashes($file2);
$sql_fc2 = " insert into test_dbb_board_file set bo_table = '$dst', wr_id = '$id', bf_no = '$bf_no', bf_source = '$bf_source2', bf_file = '$bf_file2', bf_download = '$row[download2]' ";
mysql_query($sql_fc2) or die(mysql_error());
}
$count_write++;
}
$sql = " update test_dbb_board set bo_count_write = '$count_write', bo_count_comment = '$count_comment' where bo_table = '$dst' ";
mysql_query($sql);
?>
Any comment would appreciated.