How does MySQL use PHP to batch insert? For example, after the end of the first 1000 data processing, then processing 1001 to 2000, and then processing 2001 to 3,000 ... until the whole process is finished?
When the amount of data in the table member is small, it can be executed once:
$q = "SELECT * from member '";
$r = $obj _db->simplequery ($q);
while ($a = $obj _db->fetchrow ($r, Db_fetchmode_assoc)) {
$id = $a [id];
$MCCD = $a [cca]+ $a [CCB];
$query = "INSERT into Mingxi (mid,mccd,mtime) VALUES (' $id ', ' $MCCD ', ' $time ')";
$obj _db->simplequery ($query);
}
However, when the amount of data in the member reaches millions, the execution timeout error is said to occur:
Fatal error:maximum execution time of seconds exceeded in D:
So how to real-batch processing, such as the first 1000 data processing after the end of processing 1001 to 2000, and then processing 2001 to 3,000 ..., until the whole process is complete?
$q = "SELECT * from member '";
$r = $obj _db->simplequery ($q);
while ($a = $obj _db->fetchrow ($r, Db_fetchmode_assoc)) {
$i + +;
$ep =1000;//This assumes that the 1th 1000 is processed and then the second 1000 is processed until the end of processing?
$id = $a [id];
$MCCD = $a [cca]+ $a [CCB];
$query = "INSERT into Mingxi (mid,mccd,mtime) VALUES (' $id ', ' $MCCD ', ' $time ')";
$obj _db->simplequery ($query);
}
Please help write detailed code, thank you! Because the code is hidden in the background, so don't consider the page by page by hand to point the way
------Solution--------------------
You can use the INSERT into Mingxi (mid,mccd,mtime) Select ID, CCA+CCB, and time from member
------Solution--------------------
$offs = isset ($_get[' offs ')? $_get[' offs ': 1;
$sql = "SELECT * from member limit $offs, 1000";
Do what you need to do.
Header ("Location: $_server[php_self]?offs=". ($offs +1000));