I have developing a SAAS based site, which i have to join two tables from two DBs, say table1 from DB1 and table2 from DB2. I have to get the matching records from table1 and table 2 using join in cakephp, but it throws error as below :
Error: SQLSTATE[42000]: Syntax error or access violation: 1142 SELECT command denied to user 'dbname'@'localhost' for table 'table_name' .
can anyone explain me how to done this using cakephp .
class table1 extends AppModel{
public $useDbConfig = 'DB1';
}
Class table2 extends AppModel{
public $useDbConfig = 'DB2';
function desc(){
$this->Store->useDbConfig = 'default';
$rslted = $this->find('all',array(
'conditions' => array('Jewel.id' =>1),
'joins' => array(
array(
'alias' => 'Store',
'table' => 'stores',
'type' => 'INNER',
'conditions' => 'Store.id = Jewel.store_id'
)
)
));
return $rslted;
}
}
while called the desc function from controller is not working throws error:
Base table or view not found: 1146 Table
'site1.site1_stores'
doesn't exist
but using the hasmany or belongsto on model will working , the join query is not working in controller