0

I want to create separate databases for different registrations. First i was doing it via multiple sub-domain manually but now i want it to be automatic after registration when anyone sign up.

This is what am thinking to implement: First i'll create a common database "user_databases" to just store "user email" and "user database name". So when any user login with his email then i will fetch its database name and then verify login password from users table of the fetched database.

But the problem is how will i achieve it? Should i include the code in database.php of Config or in each model i use $useDbConfig (i don't want to use it due to some reasons)?

Are there any better methods for it? Am i thinking right to implement it? Please help and guide.

Anupal
  • 1,502
  • 2
  • 11
  • 15
  • I did something similar, except I used subdomains to change the theme directory. You should be able to set the datasource in a similar way: http://blog.sixthpoint.com/wildcard-subdomain-prerouting/ – Sixthpoint May 12 '15 at 13:47
  • Am already using it with sub domain that is what manually I did but i want to implement to single domain where user can register and thus the URL for each user accessing the site would be same but with a account no. which would be used to know the database of that user to fetch. – Anupal May 13 '15 at 08:30

1 Answers1

0

database partitioning in cakephp is now a trivial task because of cake's event system. cakephp allows you to talk to its request and response objects early in the app startup process in form dispatch filters. markstory has written nicely about this http://mark-story.com/posts/view/using-cakephp-and-a-horizontally-sharded-database