PHP  
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  
<db2_free_stmtdb2_num_fields>
Last updated: Mon, 16 Jul 2012

db2_next_result

(no version information, might be only in CVS)

db2_next_result --  Requests the next result set from a stored procedure

说明

resource db2_next_result ( resource stmt )

警告

本函数是实验性的。本函数的行为,包括函数名称以及其它任何关于本函数的文档可能会在没有通知的情况下随 PHP 以后的发布而改变。使用本函数风险自担。

A stored procedure can return zero or more result sets. While you handle the first result set in exactly the same way you would handle the results returned by a simple SELECT statement, to fetch the second and subsequent result sets from a stored procedure you must call the db2_next_result() function and return the result to a uniquely named PHP variable.

参数

stmt

A prepared statement returned from db2_exec() or db2_execute().

返回值

Returns a new statement resource containing the next result set if the stored procedure returned another result set. Returns FALSE if the stored procedure did not return another result set.

例子 1. Calling a stored procedure that returns multiple result sets

In the following example, we call a stored procedure that returns three result sets. The first result set is fetched directly from the same statement resource on which we invoked the CALL statement, while the second and third result sets are fetched from statement resources returned from our calls to the db2_next_result() function.

<?php
$conn
= db2_connect($database, $user, $password);

if (
$conn) {
 
$stmt = db2_exec($conn, 'CALL multiResults()');

  print
"Fetching first result set\n";
  while (
$row = db2_fetch_array($stmt)) {
  
var_dump($row);
  }

  print
"\nFetching second result set\n";
 
$res = db2_next_result($stmt);
  if (
$res) {
   while (
$row = db2_fetch_array($res)) {
    
var_dump($row);
   }
  }

  print
"\nFetching third result set\n";
 
$res2 = db2_next_result($stmt);
  if (
$res2) {
   while (
$row = db2_fetch_array($res2)) {
    
var_dump($row);
   }
  }

 
db2_close($conn);
}
?>

上例将输出:

Fetching first result set
array(2) {
  [0]=>
  string(16) "Bubbles         "
  [1]=>
  int(3)
}
array(2) {
  [0]=>
  string(16) "Gizmo           "
  [1]=>
  int(4)
}

Fetching second result set
array(4) {
  [0]=>
  string(16) "Sweater         "
  [1]=>
  int(6)
  [2]=>
  string(5) "llama"
  [3]=>
  string(6) "150.00"
}
array(4) {
  [0]=>
  string(16) "Smarty          "
  [1]=>
  int(2)
  [2]=>
  string(5) "horse"
  [3]=>
  string(6) "350.00"
}

Fetching third result set
array(1) {
  [0]=>
  string(16) "Bubbles         "
}
array(1) {
  [0]=>
  string(16) "Gizmo           "
}




<db2_free_stmtdb2_num_fields>
 Last updated: Mon, 16 Jul 2012
 
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at: http://manual.phpv.net/
Last updated: Thu Jul 7 19:13:47 2005 CST