怎么在PHP中使用mysqli同時執行多條sql查詢語句?針對這個問題,這篇文章詳細介紹了相對應的分析和解答,希望可以幫助更多想解決這個問題的小伙伴找到更簡單易行的方法。
query("set names 'utf8'"); //多條sql語句 $sql = "select id,name from `user`;"; $sql .= "select id,mail from `user`"; if ($mysqli->multi_query($sql)){//使用multi_query()執行一條或多條sql語句 do{ if ($rs = $mysqli->store_result()){//store_result()方法獲取第一條sql語句查詢結果 while ($row=$rs->fetch_row()){ var_dump($row); echo "
"; } $rs->Close(); //關閉結果集 if ($mysqli->more_results()){ //判斷是否還有更多結果集 echo "
"; } } }while($mysqli->next_result()); //next_result()方法獲取下一結果集,返回bool值 } $mysqli->close(); //關閉數據庫連接 ?>
關于怎么在PHP中使用mysqli同時執行多條sql查詢語句問題的解答就分享到這里了,希望以上內容可以對大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關注創新互聯行業資訊頻道了解更多相關知識。