MySQLi - Use Result
语法
mysqli_result mysqli::use_result ( void )
定义和用法
它用于启动结果集检索
示例
试试下面的例子 −
<?php $servername = "localhost:3306"; $username = "root"; $password = ""; $dbname = "TUTORIALS"; $conn = new mysqli($servername, $username, $password, $dbname); if (!$conn->real_connect($servername, $username, $password, $dbname)) { die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error()); } echo "Database connected"; $query = "SELECT CURRENT_USER();"; $query .= "SELECT name FROM tutorials_auto ORDER BY ID"; if ($conn->multi_query($query)) { do { if ($result = $conn->use_result()) { while ($row = $result->fetch_row()) { printf("%s ", $row[0]); } $result->close(); } if ($conn->more_results()) { printf("****************** "); } } while ($conn->next_result()); } mysqli_close($conn); ?>
上述代码的示例输出应该是这样的 −
Database connectedroot@localhost ****************** sai ram sairamkrishna sai