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

ocinewcursor

(PHP 3 >= 3.0.8, PHP 4, PHP 5)

ocinewcursor --  ·µ»ØÒ»¸öеÄÓαê(Óï¾ä¾ä±ú)

ÃèÊö

resource ocinewcursor ( resource conn )

ocinewcursor() ÔÚÌض¨µÄÁ¬½ÓÉÏ·ÖÅäÒ»¸öеÄÓï¾ä¾ä±ú¡£

例子 1. ´ÓÒ»¸ö Oracle µÄ´¢´æ¹ý³ÌÖÐʹÓÃÒ»¸ö REF CURSOR

<?php 
// suppose your stored procedure info.output returns a ref cursor in :data

$conn = OCILogon("scott", "tiger");
$curs = OCINewCursor($conn);
$stmt = OCIParse($conn, "begin info.output(:data); end;");

ocibindbyname($stmt, "data", &$curs, -1, OCI_B_CURSOR);
ociexecute($stmt);
ociexecute($curs);

while (
OCIFetchInto($curs, &$data)) {
  
var_dump($data);
}
 
OCIFreeStatement($stmt);
OCIFreeCursor($curs);
OCILogoff($conn);
?>

例子 2. ÔÚ Oracle µÄ select Óï¾äÖÐʹÓà REF CURSOR

<?php 
echo "<html><body>";
$conn = OCILogon("scott", "tiger");
$count_cursor = "CURSOR(select count(empno) num_emps from emp " .
              
"where emp.deptno = dept.deptno) as EMPCNT from dept";
$stmt = OCIParse($conn, "select deptno,dname,$count_cursor");

ociexecute($stmt);
echo
"<table border=\"1\">";
echo
"<tr>";
echo
"<th>DEPT NAME</th>";
echo
"<th>DEPT #</th>";
echo
"<th># EMPLOYEES</th>";
echo
"</tr>";

while (
OCIFetchInto($stmt, &$data, OCI_ASSOC)) {
   echo
"<tr>";
  
$dname  = $data["DNAME"];
  
$deptno = $data["DEPTNO"];
   echo
"<td>$dname</td>";
   echo
"<td>$deptno</td>";
  
ociexecute($data["EMPCNT"]);
   while (
OCIFetchInto($data["EMPCNT"], &$subdata, OCI_ASSOC)) {
      
$num_emps = $subdata["NUM_EMPS"];
       echo 
"<td>$num_emps</td>";
   }
   echo
"</tr>";
}
echo
"</table>";
echo
"</body></html>";
OCIFreeStatement($stmt);
OCILogoff($conn);
?>




<ocinewcollectionocinewdescriptor>
 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