1. insert into using INSERT INTO
Ini_set (' max_execution_time ', ' 0 ');//limit timeout, because the first kind of time is longer, simply set to 0 unlimited
$pdo = new PDO ("mysql:host=localhost;dbname=oradt_cloud1520", "root", "123456");
for ($i =0; $i <100000; $i + +) {
$str = Strrand (32);
EXEC-$pdo, "INSERT into Scan_card_picture (Uuid,account_id,handle_state,created_time,status,from_account, Accuracy,ifupdate) VALUES (' ". $str." ', ' a7kvzzyk2eyaxm2jivvpf0ls4m2ls00000001044 ', ' handled ', ' 2015-09-17 07:55:10 ', ' Active ', ' [email protected] ', ' 90 ', 1 ');
}
Using this method, the time is about 1 hours, the slow is very outrageous, there is no way, the use of the second.
2. Ini_set (' max_execution_time ', ' 0 ');
$pdo = new PDO ("mysql:host=localhost;dbname=oradt_cloud1520", "root", "123456");
$sql = "INSERT into Scan_card_picture (uuid,account_id,handle_state,created_time,status,from_account,accuracy, Ifupdate) values ";
for ($i =0; $i <100000; $i + +) {
$str = Strrand (32);
$sql. = "('". $str. "', ' a7kvzzyk2eyaxm2jivvpf0ls4m2ls00000001044 ', ' handled ', ' 2015-09-17 07:55:10 ', ' active ', ' [email Protected] ', ' 90 ', 1), ";
}
$sql = substr ($sql, 0,strlen ($sql)-1);
Var_dump ($sql);
if ($pdo, exec ($sql)) {
echo "Insert success! ";
Echo $pdo-Lastinsertid ();
}
Using this method, adding 100,000 times is a minute. Ken can run the process will be error pdo::exec (): MySQL server has gone away; you can set global max_allowed_packet=2*1024*1024*10 in the MySQL console; (Detailed reference http://www.cnblogs.com/zlx7/p/4763207.html)
3. Online search can also use things to submit (every 10 article submitted once can, but time is not the second kind of fast), you can try it yourself.
Mysql+php+pdo Bulk Add Big Data