Adapted to new joomla database access.