db2_next_result
(PECL ibm_db2 >= 1.0.0)
db2_next_result — 저장 프로시저에서 다음 결과 세트를 요청합니다.
설명
db2_next_result(resource $stmt
): resource
저장 프로시저는 0개 이상의 결과 집합을 반환할 수 있습니다. 간단한 SELECT 문에서 반환된 결과를 처리하는 것과 똑같은 방식으로 첫 번째 결과 집합을 처리하는 동안 저장 프로시저에서 두 번째 및 후속 결과 집합을 가져오려면 db2_next_result() 함수를 호출하고 결과를 고유한 이름의 PHP 변수.
매개변수
stmt
- db2_exec() 또는 db2_execute()에서 리턴된 준비된 명령문.
반환 값
저장 프로시저가 다른 결과 집합을 반환한 경우 다음 결과 집합을 포함하는 새 문 리소스를 반환합니다. 저장 프로시저가 다른 결과 집합을 반환하지 않으면 false
를 반환합니다.
Examples
예제 #1 여러 결과 집합을 반환하는 저장 프로시저 호출
다음 예에서는 세 개의 결과 집합을 반환하는 저장 프로시저를 호출합니다. 첫 번째 결과 집합은 CALL 문을 호출한 동일한 문 리소스에서 직접 가져오는 반면 두 번째 및 세 번째 결과 집합은 db2_next_result() 함수에 대한 호출에서 반환된 문 리소스에서 가져옵니다.
<?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 " }