How to know the current connection that the system is using in CakePHP 3.0?

1

Hello, I'm working with two types of connections on databases with different settings. I want to know how I can get the current connection that the page is running dynamically.

I currently use this:

 use Cake\Datasource\ConnectionManager;

 $conexao = ConnectionManager::get('default');
 $conexao->execute('set local "funcap.usuario" = "build";');

But this returns me information about the fixed connection 'default' , I wanted something more dynamic like:

 $conexão = ConnectioXxx::getCurrent();

I'm using CakePHP in version 3.0

    
asked by anonymous 29.01.2016 / 19:37

1 answer

0

This response was taken from the SOEN .

You can do this:

$this->{$modelName}->connection()->config();
    
29.01.2016 / 19:51