2024 PHP Conference Japan

odbc_next_result

(PHP 4 >= 4.0.5, PHP 5, PHP 7, PHP 8)

odbc_next_result檢查是否有可用的多個結果集

說明

odbc_next_result(Odbc\Result $statement): 布林值

檢查是否還有更多結果集可用,並允許透過 odbc_fetch_array()odbc_fetch_row()odbc_result() 等函式存取下一個結果集。

參數

statement

ODBC 結果物件。

傳回值

若還有更多結果集,則傳回 true,否則傳回 false

更新日誌

版本 說明
8.4.0 statement 現在需要一個 Odbc\Result 實例;先前需要的是 資源

範例

範例 #1 odbc_next_result()

<?php
$r_Connection
= odbc_connect($dsn, $username, $password);

$s_SQL = <<<END_SQL
SELECT 'A'
SELECT 'B'
SELECT 'C'
END_SQL;

$r_Results = odbc_exec($r_Connection, $s_SQL);

$a_Row1 = odbc_fetch_array($r_Results);
$a_Row2 = odbc_fetch_array($r_Results);
echo
"傾印第一個結果集";
var_dump($a_Row1, $a_Row2);

echo
"取得第二個結果集";
var_dump(odbc_next_result($r_Results));

$a_Row1 = odbc_fetch_array($r_Results);
$a_Row2 = odbc_fetch_array($r_Results);
echo
"傾印第二個結果集";
var_dump($a_Row1, $a_Row2);

echo
"取得第三個結果集";
var_dump(odbc_next_result($r_Results));

$a_Row1 = odbc_fetch_array($r_Results);
$a_Row2 = odbc_fetch_array($r_Results);
echo
"傾印第三個結果集";
var_dump($a_Row1, $a_Row2);

echo
"嘗試取得第四個結果集";
var_dump(odbc_next_result($r_Results));
?>

以上範例將會輸出

Dump first result set array(1) {
  ["A"]=>
  string(1) "A"
}
bool(false)
Get second results set bool(true)
Dump second result set array(1) {
  ["B"]=>
  string(1) "B"
}
bool(false)
Get third results set bool(true)
Dump third result set array(1) {
  ["C"]=>
  string(1) "C"
}
bool(false)
Try for a fourth result set bool(false)

新增註記

使用者貢獻的註記 2 則註記

mypsuedoemail at yahoo dot com
18 年前
此函式的功能與其對應的 Microsoft SQL Server 函式 mssql_next_result() 完全相同。 以上資訊相當模糊且有點誤導,因此請參考此函式的 mssql 版本以了解如何正確使用它的詳細資訊。

備註:它適用於預存程序。
carlosgoce AT gmail DOT com
11 年前
使用 dbase 時總是會傳回 false 或 -1。它無法運作。就像 odbc_num_rows 一樣。
To Top