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 11 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->loadResultArray

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

Last reviewed: Not reviewed
phpDocumentor

database->loadResultArray

Returns an array containing a single field from all the rows returned by the database query.

Syntax

array loadResultArray ( [ integer $num_in_array ] )

$num_in_array
is the numeric offset of the field in the database row.  This field is optional and if omitted will return the first field in each row (that is, field 0).

Returns null if the last database query failed.

Examples

Example: This function prints an array of titles from the Joomla categories table.

function getCategoryTitles() {
  global $database;
 
  $sql = 'SELECT id, title, description FROM #__categories';
  $database->setQuery( $sql );
  $titles = $database->loadResultArray( 1 );
  print_r( $titles );
 
}
 
getCategoryTitles();

might produce:

Array
(
    [0] => Latest
    [1] => Joomla
    [2] => Newsflash
    [3] => Contacts
)
 

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

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