downloads | documentation | faq | getting help | mailing lists | reporting bugs | sites | links | my 
search for in the  
view the version of this page
Last updated: Sun, 02 May 2004


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

ocifetchstatement -- Estrae tutte le tuple in un array


int ocifetchstatement ( resource stmt, array & variable)

ocifetchstatement() estrae tutte le tuple da un risultato ponendole in un array definito dall'utente. ocifetchstatement() restituisce il numero di tuple estratte.

Esempio 1. Esempio di ocifetchstatement()

/* OCIFetchStatement example (990624) */

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

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


$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++ ) {
      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";

add a note add a note User Contributed Notes
david at boeke dot com
16-Dec-2003 04:17
The Skip and MaxRows parameters were not added until version 4.2.1.
Previous versions of php used this syntax:

           int ocifetchstatement ( resource stmt, array &output)

The function also took a third parameter that was not documented.  ( I assume that it was a flag)
adelac05 at sprintspectrum dot com
12-Mar-2003 10:40
One thing I found with this:

If you have two tables with the same column names, you will run into problems when displaying them, i.e:

$sql = "select,,
from table1 a, table2 b, table3 c";

php will overwrite the display cell with the value.  So you wanted three cells to display and you are only getting two.  i.e.

What you wanted:

| Bob          | Jones    | 555-555-5555 |

What you got:

| Jones        | 555-555-5555 |              |

Resolution:  rename your table column names as they come in.

$sql = "select, AS NAME2,
from table1 a, table2 b, table3 c";
lzilber at hotmail dot com
03-Aug-2001 08:19
Similar to the closed bug #9520 reported by (it did not seem obvious to me):<br>
After a call to OCIFetchStatement, functions OCIColumnName, OCIColumnSize, OCIColumnType, ... will NOT work anymore on the fetched statement.<br>
Explanation ( "...after a cursor is completly read (which is what fechstatement does) this information is no longer valid."
aries at bsd dot hu
29-Dec-2000 08:41
Don't forget: you must use capital letters as column name.
waycool at audioload dot com
31-Oct-1999 07:44
Watch out for select statements which have columns with the same name (e.g. select, 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 as a_name, as b_name ...)

 Last updated: Sun, 02 May 2004
show source | credits | sitemap | contact | advertising | mirror sites 
Copyright © 2001-2004 The PHP Group
All rights reserved.
This mirror generously provided by: Italia OnLine S.p.a.
Last updated: Fri May 21 04:11:23 2004 CEST