MySQLi - Next Result
语法
bool mysqli_next_result ( mysqli $link )
定义和用法
它准备来自 multi_query 的下一个结果。
示例
试试下面的例子 −
<?php $servername = "localhost:3306"; $username = "root"; $password = ""; $dbname = "TUTORIALS"; $conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error()); exit(); } if (!mysqli_query($conn, "SET a = 1")) { printf("Errorcode: %d ", mysqli_error($conn)); } echo 'Success... ' . mysqli_get_host_info($conn) . " "; $sql = "SELECT * FROM tutorials_auto"; if ($conn->multi_query($sql)) { do { /* store first result set */ if ($result = $conn->store_result()) { while ($row = $result->fetch_row()) { printf("%s ", $row[1]); } $result->free(); } if ($conn->more_results()) { } } while ($conn->next_result()); } $conn->close(); ?>
上述代码的示例输出应该是这样的 −
Errorcode: 0 Success... localhost:3306 via TCP/IP sai ram sai