ocifetchstatement

(PHP 3>= 3.0.8, PHP 4 )

ocifetchstatement -- Retourne toutes les lignes d'un résultat

Description

int ocifetchstatement ( resource stmt, array & variable)

ocifetchstatement() retourne toutes les lignes d'un résultat dans le tableau variable. ocifetchstatement() retourne le nombre de lignes retournées.

Exemple 1. Exemple avec ocifetchstatement()

<?php
$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 "Aucune donn&eacute;es trouv&eacute;es<BR>\n";
}      
print "$nrows lignes lues<BR>\n";
 
OCIFreeStatement($stmt);
OCILogoff($conn);
?>