I have an application in CakePhp 1.2, where depends on the domain, SOME of the models have to change dinamically the database.
So I need to find an easy way to:
- Check the domain.
- Set $useDbConfig on SOME models the database required.
This function on database.php change the database depending just on the domain, but not on the model:
public function __construct(){
if (strpos(env('HTTP_HOST'), 'site_one') !== false) {
// use site_one database config
$this->default = $this->site_one;
} elseif (strpos(env('HTTP_HOST'), 'site_two') !== false) {
// use site_two database config
$this->default = $this->site_two; }
}
How can I change the database depending also on the model?
Thanks in advance.