I have seen the earlier question on this subject and tried the suggested code:
$db = (new Joomla\Database\DatabaseFactory)->getDriver('mysqli', $options);
but get an error:
An error has occurred with a eval'd field - please inform the web-site owner. Debug: Caught exception on eval of ElementName: Database is not available in constructor in 5.0.
I also tried:
$db = DatabaseFactory::getDriver('mysqli', $options);
which gave the error:
Non-static method Joomla\Database\DatabaseFactory::getDriver() cannot be called statically
How should this be done?