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


integer fetchInto ( array &$arr , integer $fetchMode = DB_FETCHMODE_DEFAULT , integer $rowNum = null )


Places a row of data from a result set into a variable you provide then moves the result pointer to the next row. The data can be formatted as an array or an object.


mixed $arr

reference to a variable to contain the row

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. Note that 0 returns the first row, 1 returns the second row, etc.

Return value

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


This function can not be called statically.


Using fetchInto()

// Once you have a valid DB object named $db...
$res =& $db->query('SELECT * FROM mytable');
while (
$res->fetchInto($row)) {
// Assuming DB's default fetchmode is
echo $row[0] . "\n";
DB result set (Previous) Fetches a row from a result set (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.