title: How to do Associations between models in different databases using cakephp 3?
body: <p>During last week I have been stuck with a scaling-related problem in cakephp 3.0.</p>
  
  <p>Basically, I designed a application for e-commerce that will serve several clients. Each store will sell its products in a specific subdomain (client1.application.com; client2.application.com, etc). All the stores will share the same application source.</p>
  
  <p>I want to have a common database for user authentication and other common resources, like tables for cities, countries, etc, so that all users can access all e-commerce stores that use this application with same login information.</p>
  
  <p>Each client will have a database with its specific resources, e.g. tables with products, sales, etc.</p>
  
  <p>I found this interesting article <a href="http://mark-story.com/posts/view/using-cakephp-and-a-horizontally-sharded-database" rel="nofollow">http://mark-story.com/posts/view/using-cakephp-and-a-horizontally-sharded-database</a> and I already implemented that solution so that cakephp can know recognize the subdomain and select client’s database as the default connection. I changed all the models (users, etc.) that I want to use the common database so that they always connect to the common database. And it’s working.</p>
  
  <p>However, I still have a problem when it comes to associations in cakephp. For example: each client has a table for administrators in their specific databases, that associates the Users table in the common_resources database so that when an administrator logs in, the application grants all the administration privileges for that subdomain. </p>
  
  <p>To sum up, the issue concerns associations between tables in different databases. 
  Thanks a lot!</p>