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.
ora_fetch
(PHP 4, PHP 5 <= 5.0.5)
ora_fetch — カーソルから 1 行分のデータを取得
説明
bool ora_fetch ( resource cursor )指定した cursor から 1 行分のデータを取得します。
(列が取り出されれば) TRUE もしくは (取り出す列がもうないか、 エラーが発生した場合) FALSE を返します。エラーが発生した場合、 詳細は ora_error() および ora_errorcode()関数を用いて調べることが できます。エラーがない場合、ora_errorcode() は 0 を返します。
ora_parse(), ora_exec(), ora_do() も参照ください。
ora_fetch
god at danielhauser dot com
10-Jun-2003 12:36
10-Jun-2003 12:36
forever at klub dot chip dot pl
28-Mar-2003 08:36
28-Mar-2003 08: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
12-Jul-2002 05:36
12-Jul-2002 05: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
}
}
22-Feb-2002 05: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
15-Jan-2000 08:54
15-Jan-2000 08: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.