![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 <?php 2 3 $mysqli=new MySQLi("localhost","root","root","database"); 4 if($mysqli->connect_error){ 5 die($mysqli->connect_error); 6 } 7 8 //定义多条sql查询语句 9 $sqls="sql语句1"; 10 $sqls.="sql语句2"; 11 $sqls.="sql语句3"; 12 13 //............// 14 15 //批量执行sql查询语句 16 if($res=$mysqli->multi_query($sqls)){ 17 do{ 18 //从mysqli连接中取出第一个结果集 19 $result=$mysqli->store_result(); 20 21 //显示mysqli result对象 22 while($row=$result->fetch_row()){ 23 foreach($row as $key=>$val){ 24 echo "$val"; 25 } 26 27 //及时释放资源 28 $result->free(); 29 30 //判断是否有结果集 31 if(!$mysqli->more_results()){ 32 break; 33 } 34 35 echo "<br/>*******新的结果集*********<br/>"; 36 }while($mysqli->next_result()); 37 } 38 39 $mysqli->close(); 40 41 ?>