Due to the previous database field design problems, not too much attention, field content, background python data directly inserted, did not do processing, the data do not want to lose, only the Site database field content
Processing, 1 million data, debugging a half-day, a lot of ideas have tried, all kinds of pits, get a night, almost spit blood, finally got
<?php
$conn =mysql_connect ("localhost", "root", "123qwe");
mysql_select_db ("Baidu", $conn);
mysql_query ("Set names UTF8");
//???????
$sql = "SELECT * from Bdres limit 0,100000";
$res =mysql_query ($sql, $conn);
$arr =array ();
while ($row =mysql_fetch_assoc ($res)) {
$arr []= $row;
}
Mysql_free_result ($res);
for ($i =0; $i <count ($arr); $i + +) {
$row = $arr [$i];
if (! $row [' res_times ']) {
$row [' Res_times ']=0;
}
$STR = $row [' Res_times '];
Var_dump ($STR);
$row [' Res_times ']=preg_replace ("/[^a-za-z0-9\.\-]/", "", $str);
$res _id= $row [' res_id '];
$real _url= $row [' Real_url '];
$uk = $row [' UK '];
$res _title= $row [' Res_title '];
$res _cate= $row [' res_cate '];
$res _size= $row [' res_size '];
$res _times= $row [' res_times '];
$sql 2= "INSERT into share_file values (' $res _id ', ' $real _url ', ' $uk ', ' $res _title ', ' $res _cate ', ' $res _size ', ' $res _times ' ‘)";
Var_dump ($sql 2);
$res _bool=mysql_query ($sql 2, $conn);
if (! $res _bool) {
echo 0;
}else{
if (Mysql_affected_rows ($conn) >0) {
Echo 1;//indicates successful execution
}else{
Echo 2;
}
}
}
Mysql_close ($conn);
PHP operation MySQL