I often need a quick and easy few lines to retrieve some data from MySQL using Joomla without all the MVC nonsense that usually goes about this topic.

So here is how I do it!

[code lang=”php”]
$dbSEL = JFactory::getDbo();
$dbSEL->setQuery(“SELECT MAX(`start_price`) FROM #__some_table”);
echo $dbSEL->fetchRow();

As you can see above, we get the current database object and then run a query on it.
You may notice the hash (#) in the SQL statement of this example, Joomla replaces that (as well as the underscores (__) with the database prefix which is configured, so on shared nodes you don’t have to type all that extra stuff that will need to be changed later.