PHP: ora_fetch - Manual

downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

ora_getcolumn ora_fetch_into

Last updated: Fri, 26 Jan 2007

view this page in

# ora_fetch

(PHP 3, PHP 4, PHP 5 <= 5.1.0RC1)

ora_fetch -- Fetch a row of data from a cursor

## Description

bool ora_fetch ( resource cursor )

Retrieves a row of data from the specified `cursor`.

Returns `TRUE` (a row was fetched) or `FALSE` (no more rows, or an error occurred). If an error occurred, details can be retrieved using the ora_error() and ora_errorcode() functions. If there was no error, ora_errorcode() will return 0.

See also ora_parse(),ora_exec(), and ora_do().

add a note User Contributed Notes
ora_fetch
god at danielhauser dot com
09-Jun-2003 08:36
`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.`
forever at klub dot chip dot pl
28-Mar-2003 03:36
`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 at zalem dot com
11-Jul-2002 01:36
`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
}
}`
21-Feb-2002 12: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.`
dmuth at ot dot com
14-Jan-2000 03:54
`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.`
add a note
ora_getcolumn ora_fetch_into

Last updated: Fri, 26 Jan 2007
show source | credits | stats | sitemap | contact | advertising | mirror sites
Copyright © 2001-2007 The PHP Group
All rights reserved.
This mirror generously provided by: Yahoo! Inc.
Last updated: Sat Mar 10 10:36:09 2007 PST