PHP 8.1.28 Released!

odbc_next_result

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

odbc_next_result複数の結果が利用可能などうか確認する

説明

odbc_next_result(resource $statement): bool

まだ結果セットが存在して odbc_fetch_array()odbc_fetch_row()odbc_result() などで次の結果セットにアクセスできるかどうかを調べます。

パラメータ

statement

結果 ID。

戻り値

結果セットがまだある場合に true、それ以外の場合に false を返します。

例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));
?>

上の例の出力は以下となります。

最初の結果セットを出力します array(1) {
  ["A"]=>
  string(1) "A"
}
bool(false)
二番目の結果セットを取得します bool(true)
二番目の結果セットを出力します array(1) {
  ["B"]=>
  string(1) "B"
}
bool(false)
三番目の結果セットを取得します bool(true)
三番目の結果セットを出力します array(1) {
  ["C"]=>
  string(1) "C"
}
bool(false)
四番目の結果セットを調べてみます bool(false)

add a note

User Contributed Notes 2 notes

up
2
mypsuedoemail at yahoo dot com
17 years ago
This function works exactly like its equivalent Microsoft SQL Server function: mssql_next_result(). The information above is rather vague and a bit misleading, so refer to the mssql version of this function for details on to use it properly.

P.S. It works with stored procedures.
up
1
carlosgoce AT gmail DOT com
10 years ago
Using dbase always returns false or -1. It won't work. Just like odbc_num_rows.
To Top