Tutorial by Examples

App::uses('YourModel', 'Model'); $model_1 = new YourModel(array('ds' => 'default')); $model_2 = new YourModel(array('ds' => 'database2'));
For multiple databases, you have the database.php file where you can set as many databases as you need. If you want to "switch" a database for a specific model on the fly, use the setDataSource() method. For example, if you have two databases, you can define them in the database.php file...

Page 1 of 1