This article describes the PHP implementation Refresh Refresh page batch import data method. Share to everyone for your reference. The specific analysis is as follows:
This function is the reference Dedecms generate HTML page principle, just dedecms use is JS jump turn I use is the refresh to jump, the effect is the same, the following we look at a PHP implementation of the method of batch import data.
Because I have 1000W of data. Importing the database at once is not going to work, so I've caused you to import 50 or more data at a time, and then refresh it again so that you can solve the problem with the following code:
Copy Code code as follows:
<?php
Set_time_limit (0);
Connecting to a database
$s = isset ($_get[' s ']) $_get[' s ']:0;
$e = isset ($_get[' e ']) $_get[' e ']:50;
$count = 85000;
if ($s < $count)
{
$sql = "SELECT * from Bac_info where Isget =0 the ORDER by id desc limit $s, $e";
$query = mysql_query ($sql);
while ($rs = Mysql_fetch_array ($query))
{
$id = $rs [' id '];
$sms = $rs [' SMS '];
$typeid = $rs [' typeid '];
$isget = $rs [' Isget '];
$sql = "INSERT into Bac_info_bak (id,sms,typeid,isget) VALUES (' $id ', ' $sms ', ' $typeid ', ' $isget ')";
mysql_query ($sql);
Echo $sql;
Exit
$sqlu = "Update bac_info set isget=1 where id =". $rs [' id '];
mysql_query ($SQLU);
}
Echo ' <meta http-equiv= "Refresh" content= "0;url=rand.php?s=". ($s +50). ' &E=50 "> Processing data, currently '. $s ... ' ... ';
}
Else
{
Echo ' completes all data processing <a href=rand.php> and then randomly sorts once </a> ';
}
?>
I hope this article will help you with your PHP program design.