JFactory::getDbo() deprecated-- what's the replacement?

by user101289   Last Updated April 13, 2019 23:10 PM

I'm running Joomla 3.9.5 and I'm attempting to update my JFactory::getDbo() calls (which are deprecated) to the newer format using the container. However, I'm getting the following error: Call to undefined method Joomla\CMS\Factory::getContainer()

The code looks like

$db = \Joomla\CMS\Factory::getContainer()->get('DatabaseDriver');

which looks the same as what's being used in the deprecated method in \Joomla\CMS\Factory:

self::$database = self::getContainer()->get('DatabaseDriver');

What's the right way to get a DBO in the new containerized system?



Related Questions


Updated September 15, 2017 02:10 AM

Updated July 31, 2017 12:10 PM

Updated June 29, 2015 15:04 PM

Updated May 22, 2015 21:04 PM

Updated May 21, 2015 21:04 PM