<?php $mysqli = new mysqli("localhost","root","root","world"); $query = "SELECT Name FROM City;"; $query .= "SELECT Name FROM Country;"; if($mysqli->multi_query($query)){ do{ if($result = $mysqli->store_result()){ while($row = $result->fetch_row()){ printf("Col: %s<br />", $row[0]); } $result->close(); } echo "<hr />"; } while ($mysqli->more_results() && $mysqli->next_result()); } $mysqli->close(); 注意while条件的写法while ($mysqli->more_results() && $mysqli->next_result()),按书中的写法会报错.
PHP MySQL多重语句的样板代码
最新推荐文章于 2022-05-28 15:20:50 发布