ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:reference:recordset:fetchnextobj

fetchNextObj

obj fetchNextObj(
    optional bool $upperCaseKeys=false
    )
obj fetchNextObject(
    optional bool $upperCaseKeys=true
    )

fetchNextObject

Description

The fetchNextObj() / fetchNextObject() functions return the current record from a recordset as an object or false if past end-of-file, and advance the record pointer.

fetchNextObj() and fetchNextObject() can be considered as aliases, except for the fact that the latter converts the field names to uppercase by default, whereas fetchNextObj() does not.

The fetchObj method is similar, but does not affect the record pointer. It is recommended that the 2 methods are not mixed in the same procedure.

Usage

/*
 * Connection assumed
 */
$result = $db->Execute('SELECT * FROM Employees');
while (!$result->EOF){
    $obj = $result->fetchNextObj();
    print_r($obj);
    /*
     * Prints :
     * 
     * 
    ADOFetchObj Object
    (
        [emp_no] => 10001
        [birth_date] => 1953-09-02
        [first_name] => Georgi
        [last_name] => Facello
        [gender] => M
        [hire_date] => 1986-06-26
    )
}
   
v5/reference/recordset/fetchnextobj.txt · Last modified: 2023/06/11 12:02 by dregad