略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: odbc_next_result

2024-12-22

odbc_next_result

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

odbc_next_resultChecks if multiple results are available

说明

odbc_next_result(resource $statement): bool

Checks if there are more result sets available as well as allowing access to the next result set via odbc_fetch_array(), odbc_fetch_row(), odbc_result(), etc.

参数

statement

The result identifier.

返回值

Returns true if there are more result sets, false otherwise.

范例

示例 #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 
"Dump first result set";
var_dump($a_Row1$a_Row2);

echo 
"Get second results set ";
var_dump(odbc_next_result($r_Results));

$a_Row1 odbc_fetch_array($r_Results);
$a_Row2 odbc_fetch_array($r_Results);
echo 
"Dump second result set ";
var_dump($a_Row1$a_Row2);

echo 
"Get third results set ";
var_dump(odbc_next_result($r_Results));

$a_Row1 odbc_fetch_array($r_Results);
$a_Row2 odbc_fetch_array($r_Results);
echo 
"Dump third result set ";
var_dump($a_Row1$a_Row2);

echo 
"Try for a fourth result set ";
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)
add a noteadd a note

User Contributed Notes 2 notes

up
2
mypsuedoemail at yahoo dot com
16 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
9 years ago
Using dbase always returns false or -1. It won't work. Just like odbc_num_rows.

官方地址:https://www.php.net/manual/en/function.odbc-next-result.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3