Documentation Menu

1.5 Template Project

The Joomla! Documentation Working Group is running a project to develop detailed reference and tutorial material on Joomla! 1.5 templates.  There is a project page on the documentation wiki where you can see the work in progress and help us by contributing your knowledge.

Who's Online

We have 5 guests online

Help Site License

The Joomla! Help Site content is copyright © 2005 - 2008 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution NonCommercial ShareAlike 2.5. Some parts of this website may be subject to other licenses.
Home arrow Manual arrow 11. API Reference arrow [REVIEW] database->loadAssocList

[REVIEW] database->loadAssocList PDF Print E-mail

Last reviewed: Not reviewed
phpDocumentor

database->loadAssocList

Loads an associative list of database rows.

Syntax

array loadAssocList ( string $key )

$key
is the field name of the primary key.  This parameter is optional and if omitted will default to empty.

Examples

Example: The function in this example echoes an associative array of fields from the Joomla categories table.

function getCategories() {
  global $database;
 
  $sql = 'SELECT * FROM #__categories';
  $database->setQuery( $sql );
  $rows = $database->loadAssocList();
  print_r( $rows );
 
}
 
getCategories();

might produce:

Array
(
    [0] => Array
        (
            [id] => 1
            [parent_id] => 0
            [title] => Latest
            [name] => Latest News
            [image] => taking_notes.jpg
            [section] => 1
            [image_position] => left
            [description] => The latest news from the Joomla Team
            [published] => 1
            [checked_out] => 0
            [checked_out_time] => 2000-00-00 00:00:00
            [editor] => 
            [ordering] => 0
            [access] => 0
            [count] => 1
            [params] => 
        )
 
    [1] => Array
        (
            [id] => 2
            [parent_id] => 0
            [title] => Joomla
            [name] => Joomla
            [image] => clock.jpg
            [section] => com_weblinks
            [image_position] => left
            [description] => A selection of links that are all related to the Joomla project.
            [published] => 1
            [checked_out] => 0
            [checked_out_time] => 0000-00-00 00:00:00
            [editor] => 
            [ordering] => 0
            [access] => 0
            [count] => 0
            [params] => 
        )
}
 

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

Last Updated ( Monday, 25 December 2006 )
 
< Prev   Next >