Your loop can be optimized by pulling the prepare and bind_param statements out of the loop.$value = null;$mysqli->autocommit(FALSE);$sql = "INSERT INTO temp (`fund_id`) VALUES (?)";$stmt = $mysqli->prepare($sql);$stmt->bind_param('i', $value);foreach ($pdata as $value) { $stmt->execute();}$mysqli->commit();您已使用 autocommit(FALSE) 行关闭自动提交,因此不需要使用 START TRANSACTION 语句.You have turned off autocommit with your autocommit(FALSE) line and therefore don't need to use the START TRANSACTION statement. 这篇关于PHP 在循环中准备语句和事务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-14 22:51