Hello I'm currently building a SaaS application using cakePHP. I've worked with cakePHP before a few times and I'm comfortable with how it all works.
So, I have an `accounts` table which holds information about each tenant, and then a `users` table aswell, which will contain the users for each account/tenant. New users will initially be added through a basic plain PHP or WordPress front-end, so there won't be the need to create new `accounts` through the cakePHP side of the app. Just to be clear, each tenant will be on a subdomain of the main domain. For example, http://dylan.mycakeapp.dev/ could be a tenant. The front-end site will be held in the root of the site, http://mycakeapp.dev/. When new users sign up on the front-end site, their `accounts` record and a single `users` record will be created, they will get redirected to their subdomain, and the cakePHP app will take it from there. So here's the problem. I want all tenants to share the same database, separated by an 'account_id' which will be in all tables. I'm not 100% on this, but I think the correct approach is to use the 'beforeSave', 'beforeDelete' and 'beforeFind' callbacks in the model, and simply add the `account_id` as a query condition. The problem comes when I'm trying to detect which tenant to use, because I can't use the database within the model. Does anyone have any experience with SaaS/multi-tenancy apps in cakePHP, and can help? Thanks in advance. Cheers -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php