Table of Contents

loadObjectList

API Package Subpackage Class Method Reference Last reviewed Doc status
API Home Package Joomla.Framework Subpackage Database Class JDatabase Method loadObjectList Reference loadObjectList() Never Work in Progress

Returns an array of database objects using the current SQL query. Returns false if the query fails. If the $key parameter is set, the array is indexed using the values of the field specified by key. Otherwise, the array is indexed sequentially.

Syntax

array loadObjectList ( $key )

$key string is a string containing the field name of a primary key. This parameter is optional and if omitted the returned array will be ordered sequentially.

Examples

Example

$dbo =& JFactory::getDBO();

$query = "SELECT bid, name, clickurl FROM #__banner";
$dbo->setQuery( $query );
$row =& $dbo->loadObjectList();
print_r( $row );

might produce:

Result

Array
(
    [0] => stdClass Object
        (
            [bid] => 1
            [name] => OSM 1
            [clickurl] => http://www.opensourcematters.org
        )

    [1] => stdClass Object
        (
            [bid] => 2
            [name] => OSM 2
            [clickurl] => http://www.opensourcematters.org
        )

    [2] => stdClass Object
        (
            [bid] => 3
            [name] => Joomla!
            [clickurl] => http://www.joomla.org
        )

    [3] => stdClass Object
        (
            [bid] => 4
            [name] => Joomla! Forge
            [clickurl] => http://forge.joomla.org
        )

    [4] => stdClass Object
        (
            [bid] => 5
            [name] => Joomla! Extensions
            [clickurl] => http://extensions.joomla.org
        )

)