Recent Comments
2 - Notes for MySQL
Some things I noticed while researching how to get this to work.
A working example of how to configure this is below.
But first a few things to note:
0) The Username & Password for your two different DB's HAVE to be different in order for this to work. (Hat tip to Grant Cox**. )
1) Make sure that your two users have access to their respective DB.
2) Make sure to define the $userDbConfig variable in your model.
3) Make sure that the assigned value of the name of the alternate DB is the text string name of the defined alternate DB variable in your Database.php file. (The example below is "$useDbConfig = 'alternate';" and my alternate DB is defined in the Database.php file as "$alternate")
4) Make sure that your persistent variable is set to FALSE in both of your database definitions (e.g. 'persistent' => false,).
Cheers & Good Luck
~P
** (Grant Cox) - http://groups.google.com/group/cake-php/browse_thread/thread/b760aa1018de12d7
Example :
~~~~~~~~~~ /app/config/database.php ~~~~~~~~~~~~~~
var $default = array(
'driver' => 'mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'user1',
'password' => 'password1',
'database' => 'db1',
'prefix' => '',
);
var $alternate = array(
'driver' => 'mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'user2',
'password' => 'password2',
'database' => 'db2',
'prefix' => '',
);
~~~~~~~~~~~~ /app/models/externaldbmodel.php ~~~~~~~~~~~
class Externaldbmodel extends AppModel {
var $name = 'Externaldbmodel';
var $useDbConfig = 'alternate';
}



























By unknown on 27/6/08
1 - It is not clear what is this variable
This variable (and the following ones listed in this page) are not database fields, they need to be declared as:
var $useDbConfig
in your Model definition.