How dynamic does your DDC need to be? I guess the question is, are you
building the connection based on user input and controller logic? If
not you can build whatever you need in the config/database.php file.
I replaced database.php with this code, and then created
database_production.php and database_testing.php.
if( stristr($_SERVER['HTTP_HOST'],'productionDomainName.com')) {
include('database_production.php');
}else{
include('database_testing.php');
}
(I learned this trick from another post in this group... cant seem to
find it now)
This is a VERY simple example, not quite what I would call a DDC; But
maybe you can modify it for your needs.
On Mar 14, 6:07 pm, "rtconner" <[EMAIL PROTECTED]> wrote:
> Hello, I have a bit of a hard one here (on Cake 1.2.x, if it matters).
> Definitely need some ideas.
>
> I am trying to create a dynamic database connection (henceforth DDC).
> Basically all model instances will connect to the dynamically created
> connection. I can create the connection just fine
> ConnectionManager::create works wonderfully. The question is not how
> to create the connection, but WHEN to create the connection.
>
> If all Models are going to use this DDC, then it needs to be created
> before any Models are instantiated. AppController::beforeFilter runs
> too late for this (as gwoo has admitted on IRC). So it needs to be
> done earlier. I tried out bootstrap, but in bootstrap,
> ConnectionManager has not yet been instantiated yet, so bootstrap is
> too early (I could be wrong, but my testing led me to believe this is
> true)
>
> The question then is, what would the middle ground be. How would I go
> about doing this, having the connection manager already created, but
> the Model instances not yet created? I'm trying my hardest not to hack
> into cakes core code in order to implement this.
>
> Thank you for your help,
> Rob
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---