定義和用法
這個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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。