Table of Contents

_getList

API Package Subpackage Class Method Reference Last reviewed Doc status
API Home Package Joomla.Framework Subpackage Application Class JModel Method _getList Reference _getList() Never Work in Progress

Returns an object list based on the specified query.

This is a protected method that can be used to retrieve the model’s data. It provides handling for selecting a subset of the total records of the query.

Syntax

array &_getList ( $query, $limitstart, $limit )

$query string is a string containing the query to be used to obtain the data list.
$limitstart integer is an integer containing the record from which to start retrieving data. This parameter is optional and if omitted defaults to 0.
$limit integer is an integer containing the number of records to retrieve. This parameter is optional and if omitted defaults to 0, resulting in all records being retrieved.

Examples

Example

jimport( 'joomla.application.component.model' );

class PollModelPoll extends JModel
{
	function __construct() {
		$config = array(
			'table_path' => JPATH_COMPONENT.DS.'tables'
		);
		parent::__construct( $config );
	}

	function getData() {
		$query = 'SELECT * FROM #__polls';
		return $this->_getList( $query );
	}
}

$model =& JModel::getInstance( 'poll', 'PollModel' );
$data =& $model->getData();
print_r( $data );

might produce

Result

Array ( [0] => stdClass Object ( [id] => 14 [title] => Joomla! is used for? [alias] => joomla-is-used-for [voters] => 7 [checked_out] => 0 [checked_out_time] => 0000-00-00 00:00:00 [published] => 1 [access] => 0 [lag] => 86400 ) )