OCIFetchStatement

(PHP 3 = 3.0.8, PHP 4 )

OCIFetchStatement -- 結果データの全ての行を配列に取得する

説明

int OCIFetchStatement ( int stmt, array variable)

OCIFetchStatement() 結果から全ての行をユーザが 定義した配列に取得します。 OCIFetchStatement() は取得した行の数を返します。

例 1OCIFetchStatement

 ?php
/* OCIFetchStatement example mbritton@verinet.com (990624) */

$conn = OCILogon("scott","tiger");

$stmt = OCIParse($conn,"select * from emp");

OCIExecute($stmt);

$nrows = OCIFetchStatement($stmt,$results);
if ( $nrows   0 ) {
   print " TABLE BORDER=\"1\" \n";
   print " TR \n";
   while ( list( $key, $val ) = each( $results ) ) {
      print " TH $key /TH \n";
   }
   print " /TR \n";
   
   for ( $i = 0; $i   $nrows; $i++ ) {
      reset($results);
      print " TR \n";
      while ( $column = each($results) ) {   
         $data = $column['value'];
         print " TD $data[$i] /TD \n";
      }
      print " /TR \n";
   }
   print " /TABLE \n";
} else {
   echo "No data found BR \n";
}      
print "$nrows Records Selected BR \n";
 
OCIFreeStatement($stmt);
OCILogoff($conn);
?