bool mysqli_multi_query ( mysqli $link , string $query );
它用于对数据库使用分号分隔查询。
Sr.No | 参数 & Description |
---|---|
1 |
link 它指定要使用的MySQL连接 |
2 |
query 一个或多个用分号分隔的查询 |
成功时返回TRUE,失败时返回FALSE。
<?php $connection_mysql=mysqli_connect("localhost","user","pass","db"); if (mysqli_connect_errno($connection_mysql)){ echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $sql="SELECT Lastname FROM Persons;SELECT Country FROM Customers"; if (mysqli_multi_query($connection_mysql,$sql)){ do{ if ($result=mysqli_store_result($connection_mysql)){ while ($row=mysqli_fetch_row($result)){ printf("%s\n",$row[0]); } mysqli_free_result($connection_mysql); } }while (mysqli_next_result($connection_mysql)); } mysqli_close($connection_mysql); ?>
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)