$db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('*') ->from('#__users') ->where('username = ' . $db->q('john')); $db->setQuery($query); $results = $db->loadObjectList();
use Joomla\CMS\Factory; use Joomla\CMS\Database\DatabaseDriver; $db = Factory::getDbo(); $driver = $db->getDriver(); if ($driver instanceof DatabaseDriver) { echo 'Database driver: ' . $driver->getName(); }In this example, we are using getDbo to get a database object, and then we are calling the getDriver method to get the database driver object. We then check if the driver object is an instance of the DatabaseDriver class, and if it is, we display the name of the driver. The package library for getDbo is the Joomla! CMS.