How do I know the current connection the system is using in Cakephp 3.0?

Asked

Viewed 81 times

1

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

Currently I 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

1 answer

0


That answer was taken from SOEN .

You can do it like this:

$this->{$modelName}->connection()->config();

Browser other questions tagged

You are not signed in. Login or sign up in order to post.