I have developed custom pages in a Joomla 3 portal, which access an external mysql DB. To access the external db from these custom scripts, in order to add custom code to execute at each access, I have defined an additional joomla DB driver, extending the native one:
Code: Select all
<?php
/**
MySQLi database driver CUSTOM
*/
class JDatabaseDriverMysqlibz extends JDatabaseDriverMysqli
{
public function executeBz()
{
// bla bla custom code
// .....
return parent::execute();
}
}
Code: Select all
//---------------- Set custom database driver (the db used for functions NOT related to the joomla portal)
$option = array();
$option['driver'] = 'MysqliBz'; // Database driver name
$option['host'] = 'XXXXHOST'; // Database host name
$option['user'] = 'XXXUSR'; // User for database authentication
$option['password'] = 'XXXPWD'; // Password for database authentication
$option['database'] = 'XXXDB'; // Database name
$option['prefix'] = ''; // Database prefix (may be empty)
$customDBinstance = JDatabaseDriver::getInstance( $option );
Now, I am porting this solution to a Joomla 4 portal, but it is not working.
What I get is the error:
Unable to load Database Driver: bz
thrown at:
JROOT/libraries/vendor/joomla/database/src/DatabaseFactory.php:46
The DatabaseFactory scripts looks for a class named :
Joomla\Database\Bz\BzDriver
How can I extend the native DB class to create my custom class extension?
Any suggestion is appreciated.
Thank you!
M