views:

98

answers:

1

I'm having trouble creating a page, which requires two different databases..

The controller is automaticly set to 'DB2', which is also specified in the database config file.

When i add a var $uses = array ('groups') to the controller, which is from the other DB (DB1), i get the data from only DB2 and all requests to DB1 become a invalid query..

u guys know a solution?

Thanks in advance!

Regards, Swen

A: 

If have multiple datasources defined in your config/database.php file, you should be able to tell your Group model to use the second (non-default) config:

public $useDbConfig = 'db2';

Your config/database.php file should looks something like this:

class DATABASE_CONFIG {

  var $default = array(
    'driver' => 'mysql',
    'persistent' => false,
    'host' => 'your_host',
    'login' => 'your_login_1',
    'password' => 'your_password_1',
    'database' => 'DB1', 
    'prefix' => '' 
  );

  var $db2 = array(
    'driver' => 'mysql',
    'persistent' => false,
    'host' => 'your_host',
    'login' => 'your_login_2',
    'password' => 'your_password_2',
    'database' => 'DB2', 
    'prefix' => '' 
  );
}
Rob Wilkerson