|
|
Fetching Rows
Oracle Tips by Burleson Consulting |
So far, the details about connect, connect
options and handling errors have been described with data fetches
present in the examples. The methods to fetch data are a part of the
result set class. As expected the fetching mechanism in PEAR DB is
based on or similar to the one in OCI8. The methods used to fetch
data from the result set are called fetchInto() and
fetchRow(). The syntax for
the fetchInto(), taken directly from the online manual, is
shown as follows:
Synopsis
]])
Description
Places a row of data from a result set into the
variable provided and moves the result pointer to the next row. The
data can be formatted as an array or as an object.
Parameter
Contains a reference to a variable to contain
the row integer $fetchMode
which is the fetch mode to use. The default is
DB_FETCHMODE_DEFAULT, which tells this
method to use database's current fetch mode. The database's current
default fetch mode can be changed using setFetchMode().
Potential values include:
-
DB_FETCHMODE_ORDERED
-
DB_FETCHMODE_ASSOC
-
DB_FETCHMODE_OBJECT
Integer $rowNum
is the row number to fetch the
integer - DB_OK if a row is processed, NULL
when the end of the result set is reached or a DB_Error object on
failure.
The fetchRow() method is identical in all
aspects to the fetchInto(), except the fetchRow() method
creates a new array to hold the resulting row, while the fetchinto()
method fetches into the already existing one. Fetching modes are the
same as in the OCI8 module; associative array, array indexed by
numbers and fetching an object. In contrast to OCI8, which fetches
rows and organizes them as both associative array and array ordered by
numbers, PEAR DB fetches from Oracle databases in the
DB_FETCHMODE_ORDERED mode by
default.
Fetching can be performed from different result
sets in different modes. This is accomplished by specifying the mode
argument with each call to the fetch method, and in rare occasions,
the default mode can be set for the entire session.
The syntax is simple and expected as follows:
$db->setFetchMode(
int mode);
The mode is, of course, one of the modes
documented for the fetchInto() method.
SEE CODE DEPOT FOR FULL SCRIPTS
http://www.rampant-books.com/book_2005_2_php_oracle.htm
|
Expert Remote DBA
BC is America's oldest and largest Remote DBA Oracle support
provider. Get real Remote DBA experts, call
BC Remote DBA today. |
|
|