Merged JDatabaseQuery format(). Merge from platform #1604

Merged from
https://github.com/joomla/joomla-platform/commit/7371b366c8a61c9a1653e9f37c7ced1c7e3809d9