AJM.MARTINEZ
AJM.MARTINEZ

Reputation: 479

Connect to more than one database

I'm using 4.1.4 Is it possible to define a connection to another database and use it with dsql ? I mean use the two connections.

Can I define a second connection in config-default.php and how can I reference it when I need ti query the other database ?

$config['dsn']='mysql://user:user@localhost/test';
$config['dsn']='mysql://user:user@localhost/test1';

Is it possible ?

Thanks

Upvotes: 1

Views: 87

Answers (1)

romaninsh
romaninsh

Reputation: 10664

It's explained right on this page: https://agiletoolkit.org/doc/dsql/how

you can probably define it through config file but under a different key.

config.php:

$config['dsn2']='mysql://user:user@localhost/test1';

Application class:

$this->api->db2=$this->api->add('DB')
    ->connect($this->api->getConfig('dsn2'));

Because you're using 4.1, you should use 'DBlite' class instead, but other than than it's the same syntax.

Upvotes: 1

Related Questions