BC remote Oracle DBA - Call (800) 766-1884
Free Oracle Tips

Oracle Consulting Oracle Training Development

Remote DBA

 

Remote DBA Plans
Remote DBA Service

 
Remote DBA Oracle Home
Remote DBA Oracle Training
Remote DBA SQL Tuning Consulting
Remote DBA Oracle Tuning Consulting
Remote DBA Data Warehouse Consulting
Remote DBA Oracle Project Management
Remote DBA Oracle Security Assessment
Remote DBA Unix Consulting
Burleson Books
Burleson Articles
Burleson Web Courses
Burleson Qualifications
Oracle Internals Magazine
Oracle Links
Remote DBA Oracle Monitoring
Remote DBA Support Benefits
Remote DBA Plans & Prices
Our Automation Strategy
What We Monitor
Oracle Apps Support
Print Our Brochure
Contact Us (e-mail)
Oracle Job Opportunities
Oracle Consulting Prices





   

 

 

 
 

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:

DB_result::fetchInto()
DB_result::fetchInto()--Fetches a row of a result set into a variable

Synopsis

integer fetchInto (array &$arr [, integer $fetchMode = DB_FETCHMODE_DEFAULT [, integer $rowNum = NULL]])

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

mixed $arr

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


The above book excerpt is from  "Easy Oracle PHP: Creating Dynamic Web Pages with Oracle Data". 

You can buy it direct from the publisher for 50%-off and get instant access to the code depot of Oracle tuning 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.

 

 

Remote DBA Service
 

Oracle Tuning Book

Free Oracle dictionary reference poster

BC Oracle support

Oracle books by Rampant

Oracle monitoring software

North Carolina Oracle Users Group

 

 Arabian horse breeder

Seeing eye horses

 

 

Burleson is the American Team

American Flag

 

 

BC Remote Oracle Support
P.O. Box 511 • Kittrell, NC, 27544

Remote DBA

Remote DBA Services

 

Copyright © 1996 -  2011 by Burleson Enterprises. All rights reserved.

Oracle® is the registered trademark of Oracle Corporation.



Hit Counter