Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cakephp 3.0 ConnectionManager, getDataSource in Controller

Tags:

cakephp-3.0

In CakePHP 3.0, what's the equivalent of calling getDataSource() from inside a controller (like $this->ModelName->getDataSource()in cakephp 2.x)?

I have tried this:

use Cake\Datasource\ConnectionManager;
$conn = ConnectionManager::get('my_connection');

Since this connection is connected already, why do I need to provide 'my_connection'?

How can I can get the DataSource from inside a Controller in CakePHP 3.0?

Thanks

like image 221
vietsys Avatar asked Nov 20 '25 03:11

vietsys


1 Answers

Database\ConnectionManager::get() has been added. It replaces getDataSource()

CakePHP Cookbook 3

like image 102
Back Charlie Avatar answered Nov 22 '25 05:11

Back Charlie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!