Given the desired SQL:

SELECT * FROM #__tablename LIMIT 5

How do I use $query to accomplish it?

$db = JFactory::getDBO();       
$query = $db->getQuery(true);
$rows = $db->loadObjectList();

1 Answer 1


Both J2.5 and 3.x will vary.

Joomla 2.5:

$db->setQuery($query, 0, 5); 

where 0 is the start/offset and 5 is the limit

Joomla 3.x


This also accepts a 2nd argument which is the offset, but is not required

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.