Delicious Bookmark this on Delicious Share on Facebook SlashdotSlashdot It! Digg! Digg



PHP : Function Reference : Oracle Functions [deprecated] : ora_fetch

ora_fetch

Fetch a row of data from a cursor (PHP 4, PHP 5 <= 5.0.5)
bool ora_fetch ( resource cursor )


Code Examples / Notes » ora_fetch

dmuth

Try using ora_fetch_into($cursor, &$results) to get the row into an array.  Yes, you need the "&" sign before the name of the variable to fetch into so that it is passed by reference and can be modified in the function.  
You should also be aware that when calling this function multiple times (like within a loop) that the array is NOT initialized, which could lead to some "ghosting" of data.  You need to initialize the array yourself, prefarably with the array() function.


god

summary: ;-)
If you are using the ora_do() function, you must use do { ... } while(ora_fetch($curs));
because of ora_do() automaticaly fetches the first row.
If you are using
$cur=Ora_Open($db_conn);
Ora_Parse($cur,$sql,0);
Ora_Exec($cur);
you must use while(ora_fetch($curs)) { ... }
because the ora_exec doesn't fetch any row.


21-feb-2002 08:01

Obviously Daniel has no idea what he is talking about!  ora_fetch() is a wonderful tool for extracting a row from the data base. Here is how:
 while(ora_fetch($cursor) == 1){     // WHILE THERE IS A ROW
    for($i=0;$i<$numCols;$i++){     // PARSE THROUGH THE COLUMNS
      echo ora_getcolumn($cursor,$i);      //  PRINT THE RESULTS
    }
  }                                    // NEXT ROW
There are many ways to modify the above code to get the desired result, but this is a basic way to parse through all of the result set.


forever

Not only when there is only one row... the described problem occurs for the FIRST row!!! even if there is 1000 rows the first one will not be displayed so described example with 'do' solve this problem for all cases.

rrosso

Little update to abovementioned. $numCols would not work.
       while(ora_fetch($curs1) == 1){                          // WHILE THERE IS A ROW
               for($i=0;$i<ora_numcols($curs1);$i++){          // PARSE THROUGH THE COLUMNS
               printf("%s", ora_getcolumn($curs1,$i));         //  PRINT THE RESULTS
               }
       }


Change Language


Follow Navioo On Twitter
ora_bind
ora_close
ora_columnname
ora_columnsize
ora_columntype
ora_commit
ora_commitoff
ora_commiton
ora_do
ora_error
ora_errorcode
ora_exec
ora_fetch_into
ora_fetch
ora_getcolumn
ora_logoff
ora_logon
ora_numcols
ora_numrows
ora_open
ora_parse
ora_plogon
ora_rollback
eXTReMe Tracker