php - oci_fetch vs. oci_fetch_array -
when advantageous use oci_fetch
on oci_fetch_array
? oci_fetch_array
returns actual array, oci_fetch
stores fetched memory somewhere in internal buffers.
are there performance differences between 2 should know about?
with oci_fetch()
, next result row read internal buffers can read oci_result()
. call this:
$st_handle = oci_parse($oci_conn, 'select some_field, another_field some_table'); oci_execute($st_handle); while(oci_fetch($st_handle)) { $some_field = oci_result($st_handle, 'some_field'); var_dump($some_field); $another_field = oci_result($st_handle, 'another_field'); var_dump($another_field); }
alternately, instead of using oci_result()
can pre-define variables load internal buffer using oci_define_by_name()
this:
$st_handle = oci_parse($oci_conn, 'select some_field, another_field some_table'); oci_define_by_name($st_handle, 'some_field', $some_field); oci_define_by_name($st_handle, 'another_field', $another_field); oci_execute($st_handle); while(oci_fetch($st_handle)) { var_dump($some_field); var_dump($another_field); }
obviously, more verbose using oci_fetch_array()
or oci_fetch_object()
don't need explicitly define variables read results into.
$st_handle = oci_parse($oci_conn, 'select some_field, another_field some_table'); oci_execute($st_handle); while($row = oci_fetch_array($st_handle, oci_assoc)) { var_dump($row['some_field']); var_dump($row['another_field']); }
there shouldn't significant performance difference. either way, going need assign result set memory of variable or variables can use.
Comments
Post a Comment