定义和用法
这个mysqli_more_results()函数验证上次执行的多查询中是否有更多结果。
用法
mysqli_more_results($con)
参数
Sr.No | 参数及说明 |
---|---|
1 |
con(Mandatory) 这是一个表示与 MySQL 服务器的连接的对象。 |
返回值
如果有更多结果集(或错误),则 mysqli_more_results() 函数返回 true,如果没有更多结果集,则返回 false。
PHP版本
这个函数最初是在 PHP 版本 5 中引入的,适用于所有后续版本。
示例
以下示例演示了 mysqli_more_results() 函数的用法(程序风格) -
<?php
//Creating a connection
$con = mysqli_connect("localhost", "root", "password", "test");
//Executing the multi query
$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);
?>
这将产生以下结果 -
Name:Dhavan Age:33 Name:Rohit Age:28 Name:Kohli Age:25 :::::::::::::::::::::::::::::: Name:Raju Age:25 Name:Rahman Age:30 Name:Ramani Age:22
示例
在面向对象的风格中,这个函数的语法是 $con->more_results();以下是面向对象样式 $minus 中此函数的示例;
<?php
$con = new mysqli("localhost", "root", "password", "test");
//Multi query
$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");
}
} while ($con->next_result());
//Closing the connection
$res = $con -> close();
?>
这将产生以下结果 -
Name:Dhavan Age:33 Name:Rohit Age:28 Name:Kohli Age:25 :::::::::::::::::::::::::::::: Name:Raju Age:25 Name:Rahman Age:30 Name:Ramani Age:22
相关用法
- PHP mysqli_multi_query()用法及代码示例
- PHP mysqli_get_server_info()用法及代码示例
- PHP mysqli_data_seek()用法及代码示例
- PHP mysqli_insert_id()用法及代码示例
- PHP mysqli_fetch_assoc()用法及代码示例
- PHP mysqli_connect_error()用法及代码示例
- PHP mysqli_fetch_all()用法及代码示例
- PHP mysqli_next_result()用法及代码示例
- PHP mysqli_stmt_affected_rows()用法及代码示例
- PHP mysqli_begin_transaction()用法及代码示例
- PHP mysqli_real_escape_string()用法及代码示例
- PHP mysqli_fetch_lengths()用法及代码示例
- PHP mysqli_character_set_name()用法及代码示例
- PHP mysqli_free_result()用法及代码示例
- PHP mysqli_fetch_row()用法及代码示例
- PHP mysqli_debug()用法及代码示例
- PHP mysqli_commit()用法及代码示例
- PHP mysqli_fetch_field()用法及代码示例
- PHP mysqli_kill()用法及代码示例
- PHP mysqli_thread_safe()用法及代码示例
注:本文由纯净天空筛选整理自 PHP mysqli_more_results() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。