★ wanayoo — archive 1999 http://www.php.net/manual/function.ocifetchstatement.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to OCI8
Quick Reference
German version of this pageJapanese version of this pageItalian version of this pageFrench version of this pageHungarian version of this page
OCI8
* OCIDefineByName
* OCIBindByName
* OCILogon
* OCIPLogon
* OCINLogon
* OCILogOff
* OCIExecute
* OCICommit
* OCIRollback
* OCINewDescriptor
* OCIRowCount
* OCINumCols
* OCIResult
* OCIFetch
* OCIFetchInto
* OCIFetchStatement
* OCIColumnIsNULL
* OCIColumnSize
* OCIServerVersion
* OCIStatementType
* OCINewCursor
* OCIFreeStatement
* OCIFreeCursor
* OCIColumnName
* OCIColumnType
* OCIParse
* OCIError
* OCIInternalDebug
Manual: OCIFetchStatement
View the source code for this pageSearch the site



Previous page
 OCIFetchInto
 Updated
Sat, 12 Aug 2000
OCIColumnIsNULL 
Next page


OCIFetchStatement

(unknown)

OCIFetchStatement -- Fetch all rows of result data into an array.

Description

int OCIFetchStatement (int stmt, array &variable)

OCIFetchStatement() fetches all the rows from a result into a user-defined array. OCIFetchStatement() returns the number of rows fetched.

Example 1. OCIFetchStatement


<?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);

?>

User Contributed Notes: OCIFetchStatement


waycool@audioload.com
31-Oct-1999 01:44
Watch out for select statements which have columns with the same name (e.g. select a.name, b.name from ...) because the later results will wipe out the previous $data["name"] values. One way to get around this is to use aliases (e.g. select a.name as a_name, b.name as b_name ...)


olepretr@afrilink.net
08-May-2000 06:28
When I'm using this example with my tables, it works fine for numbers but I have some problems with CHAR and VARCHAR. Chars are not working neither under IE5 and NS4 (I have only the first char). Varchar are working fine under IE5 but not under NS4. Could someone tell me where I can be wrong or how are these types translated under PHP ?



 About Notes


Previous page
 OCIFetchInto
 Updated
Sat, 12 Aug 2000
OCIColumnIsNULL 
Next page





Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.