English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
mysqli_more_results() functionCheck if there are more query results in batch queries
Check if there are more query result sets after the previous call to mysqli_multi_query() function.
mysqli_more_results($con)
Serial number | Parameters and descriptions |
---|---|
1 | con(Required) This is an object representing the connection with the MySQL Server. |
If there are more result sets that can be read after the previous call to the mysqli_multi_query() function, it returns TRUE, otherwise it returns FALSE.
This function was originally introduced in PHP version5introduced and can be used in all higher versions.
The following examples demonstratemysqli_more_results()Usage of Function (Procedural Style)-
<?php //Establish Connection $con = mysqli_connect("localhost", "root", "password", "test"); //Execute Multiple Queries $query = "SELECT * FROM players;SELECT * FROM emp"; mysqli_multi_query($con, $query); do{ $result = mysqli_use_result($con); while($row = mysqli_fetch_row($result)){ print("Name: ".$row[0]."\n"); print("Age: ".$row[1]."\n"); print("\n"); } if(mysqli_more_results($con)){ print("::::::::::::::::::::::::::::::\n"); } }while(mysqli_next_result($con)); mysqli_close($con); ?>
Output Result
Name: Dhavan Age: 33 Name: Rohit Age: 28 Name: Kohli Age: 25 :::::::::::::::::::::::::::::: Name: Raju Age: 25 Name: Rahman Age: 30 Name: Ramani Age: 22
In an object-oriented style, the syntax of this function is$con-> more_results();.The following is an example of this function in an object-oriented style;
<?php $con = new mysqli("localhost", "root", "password", "test"); //Multiple Queries $res = $con-> multi_query("SELECT * FROM players;SELECT * FROM emp"); do { $result = $con-> use_result()); while($row = $result-> fetch_row()); print("Name: ".$row[0]."\n"); print("Age: ".$row[1]."\n"); print("\n"); } if($con-> more_results()); print("::::::::::::::::::::::::::::::\n"); } }-> next_result()); //Close Connection $res = $con -> close(); ?>
Output Result
Name: Dhavan Age: 33 Name: Rohit Age: 28 Name: Kohli Age: 25 :::::::::::::::::::::::::::::: Name: Raju Age: 25 Name: Rahman Age: 30 Name: Ramani Age: 22