php - Dynamically change database connection in cakephp 3 -
i'm trying change database connection used in cakephp 3 on fly. every answer question found refers cakephp 2 ( these three for instance). this guy found solution cakephp 3 having finite number of databases, , defining database used table file. the thing want create new database every new user, , change database when logs in. can't know in advance databases exist, write in config/app.php file. and can't set default database in each /src/model/table file, because tables same in every database. use connectionmanager::config() function create connections on fly , connnectionmanager::alias() method make table classes use default. there article describing process here: http://mark-story.com/posts/view/using-cakephp-and-a-horizontally-sharded-database the difference can create connection config on fly instead of declaring shards manually shown in article.