I do not see other solution than $useDbConfig, unless you use the
model->query() function when you access your different "named table"
instead of findAll / find etc .. Basically you would use "classic"
code instead of the "magic" of cakePhp.
Concerning the persistent connection, I think the parameter
'persistent' => false into the database config should be handled.

On May 31, 12:20 am, davo <[EMAIL PROTECTED]> wrote:
> Thanks for the suggestion francky06l - $useDbConfig was the most
> obvious solution i could see as well... the only problem is that we've
> got about 400 clients and they get added/deleted dynamically, so it's
> going to be a hell of a big config file. Also we'll probably have
> joins between the master & client databases which $useDbConfig is
> going to have trouble with (we're stuck on MySQL4 until everything's
> migrated so we don't have the luxury of views). Ideally we want to get
> the db name into the actual query, like 'select star from
> my_app_customer_x.daily_hits' if that makes sense, then we don't need
> to mess around with the actual connection too much.
>
> Samuel, can the persistent connection thing can be set in the database
> config file?
>
> On May 30, 6:21 pm, francky06l <[EMAIL PROTECTED]> wrote:
>
> > You could setup different database into the config.php, and set the
> > $useDbConfig to point to the desired database into the model. After
> > login, if all models are use the same DB you can put this into the
> > app_model.php.
>
> > On May 30, 11:07 am, davo <[EMAIL PROTECTED]> wrote:
>
> > > Hi Guys,
>
> > > We're trying to introduce cake into an existing php app, with the aim
> > > of gradually porting the old legacy spaghetti code into cake. We have
> > > to add some new features so this seems like a good time to start
> > > migrating.
>
> > > A bit of background - the application has a single 'master' database
> > > that holds login and profile information. Each user belongs to a
> > > 'profile' (basically a customer) with their own database, so after the
> > > initial login they use their own separate database for customer-
> > > specific data like crm, stats etc. So for example, if i am customer_x,
> > > i might login using a master database called 'my_app', then after i'm
> > > logged in use a database called 'my_app_customer_x'. I will still use
> > > the master 'my_app' database for some things, such as user
> > > administration etc.
>
> > > The problem I'm running into is this - depending on the user's
> > > 'profile' the model needs to use a different database. I can get the
> > > name of the database i want inside the model, but i can't figure out
> > > how to use it.
>
> > > I have overcome a similar problem before with rails by setting the
> > > table_prefix in the model to the database name (yes very hacky!), so
> > > for a 'daily_stats' model for 'customer_x', the model name is set to
> > > 'my_app_customer_x.daily_stats' at runtime, which works fine with
> > > mysql.
>
> > > This hack doesn't work at all in cake because the model keeps a list
> > > of it's tables (in $db->listSources() i think), and i am banging my
> > > head against the wall trying to think of a clean way to do this. I
> > > don't care about any DB except MySQL if that makes any difference.
> > > We'd like to avoid doing a separate mysql connection per request if
> > > possible, because we tried that before with rails and it brought the
> > > DB server down pretty quickly under load.
>
> > > I hope you guys & gals can follow what i'm getting at - any & all help
> > > would be greatly appreciated!
>
> > > thanks
>
> > > dave


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to