在 PHP 中使用一个 mysqli_query 调用更新多个 MySQL 记录 [英] Updating multiple MySQL records using one mysqli_query call in PHP
本文介绍了在 PHP 中使用一个 mysqli_query 调用更新多个 MySQL 记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须一次更新数百条记录,我想知道是否可以使用一个 mysqli_query
调用来更新所有记录.我知道不可能使用以下内容:
I have to update hundreds of records at once and I'm wondering if it's possible to use one mysqli_query
call to update all of them. I know it isn't possible to use something like:
UPDATE table SET col=value1,col=value2,col=value3 WHERE id IN (1,2,3)
是否可以以某种方式使用自定义函数或其他方法一次更新多个记录?
Is it possible to somehow use custom functions or another method to update multiple records at once?
推荐答案
使用 mysqli_multi_query()
函数,通过该函数可以连接所有查询并将其传递给 mysqli_multi_query
功能
use mysqli_multi_query()
function, by which you can concat all the queries and pass it the mysqli_multi_query
function
这篇关于在 PHP 中使用一个 mysqli_query 调用更新多个 MySQL 记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文