TRY AND ERROR

気になったこと、勉強したこと、その他雑記など色々メモしていきます。。Sometimes these posts will be written in English.,

In CakePHP3, change just a specific table class's datasource.

If you want to get the Table objects to access to DB without appalently using ConnectionManager, I think you use the "TableRegistry" like following.

TableRegistry::get("Yours");


Above then, "default" datasource in app.php is chosen.
If you use the datasource of not default, you set "defaultConnectionName" function to Model/Table/YoursTable.php

public static function defaultConnectionName() {
    return 'your datasource key';   // Defined at Datasources in app.php.
}

Just only it!