We did something a bit like this in the past. It wasn't actually based
on host name, but could easily be adapted. Basically, we had a
reporting application based on an externally populated database
(proving Cake can even work - sort of - without the convention part
and still be helpful).
Each customer had to have their own database. We create a generic,
empty template database containing only the table definitions, which
Cake used to create models, we then had a component to replace the
current default database connection with the customer specific one
based on the user (Auth->user()):
$db = ConnectionManager::getDataSource('default');
$db->reconnect('customerDatabase');
Each customer database was then defined in app/config/database.php's
DATABASE_CONFIG.
This worked, but is not optimal (additional unnecessary database
connections, and not the quickest solution, technically we could get
around that with a lazy connection patch on the DESCRIBE methods,
allowing cake's model caching to take over, and avoid the additional
'template database' connection, but this would mean a fair amount of
messing).
If anyone can think of a better way of doing it that would be great to
hear. I suppose a custom datasource might be the answer, but it would
probably make more sense for my proposed patch to enable something
like the router to control the config path and well as, say views. At
which point it starts to look more like a virtual host system for
cake.
Anyone have any comments? It seems like this could be a useful
addition for a number of cases.
Simon
http://www.simonellistonball.com/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---