What you need to do is set $useDBConfig for each model. var $useDBConfig = 'A';
then in your DATABASE_CONFIG you would use var $A = array( 'driver' => 'mysql', 'persistent' => false, 'host' => 'localhost', 'login' => 'username', 'password' => 'password', 'database' => 'A', 'prefix' => '', ); Adam On Sep 21, 4:24 am, Rick <[EMAIL PROTECTED]> wrote: > I've got an existing MySql instance that contains 4 databases (lets > call them A, B, C & D). Each has tables as you would expect. For > this post lets say tables are named like table1, table2 etc.. in each > database. My single user/password has access to all databases in the > instance. > > My problem is I need to query across several databases. This is the > way I would do this with a raw query: > > select * from A.table1 as t1, B.table2 as t2 > where t1.id = t2.id > > I haven't been able to do this through any combination of model > attributes. Naturally I thought that > > var $useTable = "A.table1" > > in The table1 model and > > var $useTable ="B.table2" > > in the table2 model would work - alas no it does not. > > I've also tried using the prefix attribute and that doesn't do it > either. > > Is there some way to do this in Cake or do I need to forget the models > and just do raw sql queries in the controllers? It seems to me this > is just an arbitrary restriction in the model code. > > Richard --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---