DB connection without config file entry
Hi there again!
I am working on data migration tool and I need to use raw DB connection using Jet\Db. I know where is the Jet\Db config file is and how to configure it.
But for my use it would be better to create ad-hoc database connection - without config file entry.
Is it possible?
Thanks!
Answers (2)
Hello :-)
It's definitely possible. Here is an example:
$config = Factory_Db::getBackendConfigInstance([
'name' => 'connection-name',
'driver' => 'mysql',
'host' => 'localhost',
'port' => 3306,
'dbname' => 'db-name',
'charset' => 'utf8',
'username' => 'username',
'password' => 'password',
]);
$db = Factory_Db::getBackendInstance( $config );
Have a nice day!
Perfect, thanks!
Your Answer
Please Sign In or Sign Up. It is really simple, and it takes only few seconds. You can use your Google account.