Lets say I have two different databases with the following tables:
Auth database:
users
App database:
fanpages
fanpages_users
Obviously my User model uses the Auth database, but how do I force HABTM relation to use the App database instead of the Auth database?
The error I am getting states:
Table fanpages_users for model FanpagesUser was not found in datasource Auth.
You need to create another model called FanspagesUser
and define $hasMany
relation on User
model and on Fanpage
model.
<?php
class FanpagesUser extends AppModel{
public $useDbConfig = 'your database configuration on databases.php';
public $belongsTo = array('User','Fanpage');
}
<?php
class Fanpage extends AppModel{
public $useDbConfig = 'your database configuration on databases.php';
public $hasMany= array('FanpagesUser');
}
<?php
class User extends AppModel{
public $useDbConfig = 'your database configuration on databases.php';
public $hasMany= array('FanpagesUser');
}