[REVIEW] database->loadRowList

Last reviewed: Not reviewed
phpDocumentor

database->loadRowList

Returns an array of database rows with numeric column indexing.  Returns null if the query fails.

Syntax

array loadRowList ( [ string $key ] )

$key
is a field name. If $key is empty then loadRowList will return a sequential list of the database records returned by the current query. If $key is not empty then the array will be indexed by the value of the database key. This parameter is optional and if omitted will default to empty.

Examples

Example: This function prints an array containing records from the Joomla categories table.  Note that in this example the array is indexed by the category title field.

function getCategories() {
  global $database;
 
  $sql = "SELECT * FROM #__categories";
  $database->setQuery( $sql );
  $categories = $database->loadRowList( 'title' );
  print_r( $categories );
 
}
 
getCategories();

might produce:

Array
(
    [Latest] => Array
        (
            [0] => 1
            [id] => 1
            [1] => 0
            [parent_id] => 0
            [2] => Latest
            [title] => Latest
            [3] => Latest News
            [name] => Latest News
            [4] => taking_notes.jpg
            [image] => taking_notes.jpg
            [5] => 1
            [section] => 1
            [6] => left
            [image_position] => left
            [7] => The latest news from the Joomla Team
            [description] => The latest news from the Joomla Team
            [8] => 1
            [published] => 1
            [9] => 0
            [checked_out] => 0
            [10] => 2000-00-00 00:00:00
            [checked_out_time] => 2000-00-00 00:00:00
            [11] => 
            [editor] => 
            [12] => 0
            [ordering] => 0
            [13] => 0
            [access] => 0
            [14] => 1
            [count] => 1
            [15] => 
            [params] => 
        )
 
    [Joomla] => Array
        (
            [0] => 66
            [id] => 66
            [1] => 0
            [parent_id] => 0
            [2] => Joomla
            [title] => Joomla
            [3] => Joomla
            [name] => Joomla
            [4] => 
            [image] => 
            [5] => com_newsfeeds
            [section] => com_newsfeeds
            [6] => left
            [image_position] => left
            [7] => 
            [description] => 
            [8] => 1
            [published] => 1
            [9] => 0
            [checked_out] => 0
            [10] => 0000-00-00 00:00:00
            [checked_out_time] => 0000-00-00 00:00:00
            [11] => 
            [editor] => 
            [12] => 2
            [ordering] => 2
            [13] => 0
            [access] => 0
            [14] => 0
            [count] => 0
            [15] => 
            [params] => 
        )
}
 

Please report any errors on this page to the Developer Documentation Forum.

Last Updated ( Monday, 25 December 2006 )