PHP.mk документација

db2_next_result

Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.

function.db2-next-result.php PHP.net прокси Преводот се освежува
Оригинал на PHP.net
Патека function.db2-next-result.php Локална патека за оваа страница.
Извор php.net/manual/en Оригиналниот HTML се реупотребува и локално се стилизира.
Режим Прокси + превод во позадина Кодовите, табелите и белешките остануваат читливи во истиот тек.
db2_next_result

Референца за `function.db2-next-result.php` со подобрена типографија и навигација.

function.db2-next-result.php

db2_next_result

(PECL ibm_db2 >= 1.0.0)

db2_next_result Requests the next result set from a stored procedure

= NULL

db2_next_result(resource $stmt): resource|false

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
Подготвена изјава вратена од 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.

Примери

Example #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);
}
?>

Пример #1 Пример што покажува затворачка ознака што го опфаќа последниот нов ред

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           "
}

Белешки од корисници 1 белешка

matthewv at ca dot ibm dot com
пред 17 години
Some not so obvious but imported notes:

1) You must always use the original statement return when fetching the next result set.
2) You can not remove a reference to a previous result set if you wish to access another result set.

----------------WILL NOT WORK-------------------------
<?php
$originalStatementReturn = db2_exec($conn, 'CALL multiResults()');

$firstResultHolder = db2_next_result($originalStatementReturn);

$secondResultHolder = db2_next_result($firstResultHolder);

if ($secondResultHolder) {
  while ($row = db2_fetch_array($secondResultHolder)) {
     print_r($row);
  }
}
?>
-----------------------------------------------------------------

----------------WILL NOT WORK-------------------------
<?php
$originalStatementReturn = db2_exec($conn, 'CALL multiResults()');

$resultHolder = db2_next_result($originalStatementReturn);

$resultHolder = db2_next_result($originalStatementReturn);

if ($resultHolder) {
  while ($row = db2_fetch_array($resultHolder)) {
     print_r($row);
  }
}
?>
-----------------------------------------------------------------

----------------WILL WORK--------------------------------
<?php
$originalStatementReturn = db2_exec($conn, 'CALL multiResults()');

$firstResultHolder = db2_next_result($originalStatementReturn);

$secondResultHolder = db2_next_result($originalStatementReturn);

if ($secondResultHolder) {
  while ($row = db2_fetch_array($secondResultHolder)) {
     print_r($row);
  }
}
?>
-----------------------------------------------------------------
Навигација

Прелистувај сродни теми и функции.

На оваа страница

Автоматски outline од активната документација.

Насловите ќе се појават тука по вчитување.

Попрегледно читање

Примерите, changelog табелите и user notes се визуелно издвоени за да не се губат во долгата содржина.

Брз совет Користи го outline-от Скокни директно на главните секции од активната страница.
Извор Оригиналниот линк останува достапен Кога ти треба целосен upstream context, отвори го PHP.net во нов tab.