SOLVED: Access secondary fabrik database connection

Status
Not open for further replies.

juuser

Well-Known Member
Hi,

I have a secondary fabrik database connection. What is a good way of accessing this connection? This works for example in calc element:

$option = array();
$option['driver'] = 'mysql';
$option['host'] = 'hostname';
$option['user'] = 'username';
$option['password'] = 'password';
$option['database'] = 'databasename';
$option['prefix'] = '';

$db = JDatabaseDriver::getInstance( $option );

But I would'nt want to add this code to every calc element. If I change a password of database, I would need to change it in every element.

Thanks,
Martin
 
Code:
$db = FabrikWorker::getDbo(false, 2);

Replace 2 with the ID of the connection.

Alternatively, if it's the connection your list is built on, you can do it without hard coding the ID ...

Code:
$db = $formModel->getListModel()->getDb();

That might vary a little depending where you are running the code, but most places in forms or elements where you can run eval'ed code, $formModel exists.

-- hugh
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Staff online

Members online

Back
Top