I am trying to connect to multiple databases in cakephp 3
. I have tried many times but all questions and answers are in cakephp 2
. I found Configuring Connections at cakephp 3
documentation. But I can't understand it.
I have two databases :
1. tracking_system
(Tables: trackers, events, etc..)
2. tracking_system_2
(Tables: todos, actions, etc..)
Working with database tracking_system is completely running. But I don't know, how to connect to multiple databases (in my case, with second database tracking_system2).
Thanks in advance for help.
You can declare the defaultConnectionName()
method on the tables that will use by default another connection. In any of your Table classes:
public static function defaultConnectionName()
{
return 'another_config_name';
}