DB_result::fetchRow() – Fetches a row from a result set


mixed &fetchRow ( integer $fetchmode = DB_DEFAULT_MODE , integer $rownum = null )


Returns a row of data from a result set then moves the result pointer to the next row. The data can be formatted as an array or an object.


integer $fetchmode

the fetch mode to use. The default is DB_FETCHMODE_DEFAULT, which tells this method to use DB's current fetch mode. DB's current default fetch mode can be changed using setFetchMode(). Potential values include:




integer $rownum

the row number to fetch

Return value

mixed - an array or object containing the row's data, NULL when the end of the result set is reached or a DB_Error object on failure


This function can not be called statically.


Using fetchRow()

// Once you have a valid DB object named $db...
$res =& $db->query('SELECT * FROM mytable');
while (
$row =& $res->fetchRow()) {
// Assuming DB's default fetchmode is
echo $row[0] . "\n";
Fetches a row of a result set into a variable (Previous) Releases a result set (Next)
Last updated: Sun, 19 Dec 2010 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report or add a note.
View this page in:

User Notes:

There are no user contributed notes for this page.