// 单条插入 for ($i = 0; $i < 1000; $i++) { $name = rand(1000, 9999); $email = rand(1000, 9999); $message = rand(1000, 9999); $insertdata = array('name' => $name, 'email' => $email, 'message' => $message); $this->commoninsertinfo($insertdata,'aa'); }
时间2秒。。。太慢了
然后看看批量插入
$insertdatalist = array(); for ($i = 0; $i < 5000; $i++) { $name = rand(1000, 9999); $email = rand(1000, 9999); $message = rand(1000, 9999); $insertdata = array('name' => $name, 'email' => $email, 'message' => $message); $insertdatalist[] = $insertdata; } $this->insertss($insertdatalist, 'aa');
0.01秒。。快100倍 或者更多