# Select,update insert specific tables from another database. In cakephp 3

**URL:** <https://discourse.cakephp.org/t/select-update-insert-specific-tables-from-another-database-in-cakephp-3/836>\
**Category:** Need Help\
**Created:** [July 28, 2016, 11:01am UTC](https://discourse.cakephp.org/t/select-update-insert-specific-tables-from-another-database-in-cakephp-3/836 "2016-07-28T11:01:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![YesNo](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/yesno/32/334_2.png) [@YesNo](https://discourse.cakephp.org/u/YesNo)\
**Post date:** [July 28, 2016, 11:01am UTC](https://discourse.cakephp.org/t/select-update-insert-specific-tables-from-another-database-in-cakephp-3/836/1 "2016-07-28T11:01:41Z")

</div>

I know.

There are some questions in here which had this already. But in my case it’s somehow different:

I have to databases. 1. Database (as default) which has User login data. When user come loggin.  
He will take this default database configuert in app.php.

The name of the 2. db I get from user-data. I can connect by defining a new db connection to the 2. database.

What is the best way to setup each model table so it will take datas from the 2. db??

```
public static function defaultConnectionName() {
    return 'customer';
}

```

expected customer has been fixed setup in app.php! So this can’t be the way…

---

<div class="post-metadata">

**Author:** ![Speudyland](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/speudyland/32/569_2.png) [@Speudyland](https://discourse.cakephp.org/u/Speudyland)\
**Post date:** [March 22, 2017, 11:51am UTC](https://discourse.cakephp.org/t/select-update-insert-specific-tables-from-another-database-in-cakephp-3/836/2 "2017-03-22T11:51:19Z")

</div>

Hi,

Did you check this answer on this related post on stackoverflow:

[Multiple database connection in cakephp 3](http://stackoverflow.com/questions/29981890/multiple-database-connection-in-cakephp-3)

And maybe have look here as well:

[connect-with-multiple-database-in-cakephp-3](http://stackoverflow.com/questions/38587294/connect-with-multiple-database-in-cakephp-3)
