更新时间:2023-01-29 08:32:51
找到了这个. PDO/PHP/MySQL中的性能:事务与直接执行一个>.所以试试这个.
found this one. Performance in PDO / PHP / MySQL: transaction versus direct execution. so try this one.
$query = $data->prepare("INSERT INTO `tbl_temp` (aid, bid) VALUES (?, ?)");
try {
$data->beginTransaction();
for($i=0; $i < 150; $i++) {
$time = time();
$query->bindValue(1, $i, PDO::PARAM_INT);
$query->bindValue(2, $time, PDO::PARAM_STR);
$query->execute();
}
$data->commit();
} catch(PDOException $e) {
$data->rollBack();
}