Hello,

> I assume that you mean "3 schemas" when you say "3 databases".

I meant "database" as in the "CREATE DATABASE" statement in MySQL.

> I think you can select which schema you want to use on the fly.
> You can define the dbconfigs on the appropriate file and then switch
> between them using the model's $useDbConfig var.

Yep, that far I succeeded.

> As of putting the models and controllers on different folders, I'm
> pretty sure you can hack some way to get it to work, but I think
> that's definitely a bad practice, so I wouldn't advise you to do so.

I was suspecting that it wouldn't be possible but decided to run it by
you guys. Thank you for clarifying this. 

> As a complement of this brief explanation and also to answer to your
> 'Problem 2.' please read the Model section fo Cake Manual. I'm pretty
> sure you'll find useful information there, as well as clear answers to
> your questions.

See, I did read the Model portion of the manual but I don't think it
answers my question. Let me go into a little more detail.

Let's say I have a MySQL database named "A" and another one named "B".
Within "A", I have a table named A1. Within "B" I have a table
named B1. Let us now say that A.A1 has a foreign key in B.B1.

So, I'm trying to write a model for A.A1 with a foreign key to B.B1.
Here's where I get stuck:

class A1 extends AppModel
{
  var $name = 'A1';
  var $useDbConfig = 'dbConfig_A';

  var $belongsTo = array('B1' => array('className' => 'B1'));
}

I think the above is more or less correct, but as you can see B1 will be
searched within database "A", not database "B". And that's the problem I
was describing. 

Even though I could specify a database connection in a model, here I
have a situation where I need both connections because the tables are in
different databases (although both are under the same instance of the
MySQL server).

Hope there's a simple answer to this problem. Thanks for all your help.

Best regards,
  Sergei

> Good luck.
> 
> On Apr 8, 2:53 pm, "[EMAIL PROTECTED]"
> <[EMAIL PROTECTED]> wrote:
> > Hi everybody,
> >
> > I'm considering converting my application into CakePHP.
> >
> > Currently I have 3 databases within my application and the first one
> > has several tables that are referenced by tables in the other two
> > databases.
> >
> > Problem 1. I have tables that are named the same in at least two
> > databases. Can models, controllers and views be isolated to a folder
> > that would correspond to a specific database? Cake Views are already
> > in a folder by the controller name but models and controllers exist in
> > the same directories.
> >
> > Problem 2. I don't know how to describe a model that has a
> > relationship with a table from a different database.
> >
> > What's the best way to handle this situation in Cake?
> 
> 
> > 

-- 

Sergei Gerasenko
IT Department
PublicSchoolWORKS
Phone: (513)-631-6111

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