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



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

ora_fetch_into

Fetch a row into the specified result array (PHP 4, PHP 5 <= 5.0.5)
int ora_fetch_into ( resource cursor, array &result [, int flags] )

Example 1680. ora_fetch_into()

<?php
$results
= array();
ora_fetch_into($cursor, $results);
echo
$results[0];
echo
$results[1];
$results = array();
ora_fetch_into($cursor, $results, ORA_FETCHINTO_NULLS|ORA_FETCHINTO_ASSOC);
echo
$results['MyColumn'];
?>

Code Examples / Notes » ora_fetch_into

herve3d

With : ora_fetch_into($curs, &$dt, ORA_FETCHINTO_ASSOC)
If the value of a field is NULL it will contains value from the row before.
To avoid this you can use :
ora_fetch_into($curs, $dt, ORA_FETCHINTO_NULLS|ORA_FETCHINTO_ASSOC);
And NULL fields remain empty.


markus dot elfring

The function "OCIFetchInto" seems to be better for special datatypes like "CLOB" or "BLOB".

kamas

becareful when fetching data with NULL value using ora_fetch_into().
table example :
field1 field2 nullable
----------------------
a b c
w w NULL
d d NULL
e e x
//php script :
$curs = ora_open($conn);
ora_parse($curs, "SELECT * FROM tableblah");
ora_exec($curs);
while(ora_fetch_into($curs, &$dt, ORA_FETCHINTO_ASSOC)) {
echo $dt['field1'] . " - " . $dt['field2'] . " - " . $dt['nullable'] . "
\n";
}
ora_close($curs);
the above code will print:
a - b - c
w - w - c
d - d - c
e - e - x
if the value of the nullable field is NULL it will contains value from the
row before. to avoid this you can use :
while(ora_fetch_into($curs, &$dt, ORA_FETCHINTO_ASSOC)) {
...
$dt['nullable'] = "";
}
to set $dt['nullable'] to an empty value.


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