php - CakePHP: associating two models using different databases? -


I have two models, plants and amps, which have many relationships and I have configured them to join and The query is correct to get data for each, but the problem is that the plant and the AMP are on different databases. I am on the database database 1, Plant is on Database 2. Because of this, they do not query properly to join; The included table is only on database 1.

When the plant tries to use the table of joining, then it is querying Database 2, which does not have this data.

It is for the Association Emp Plant.

  is $ var and Belongsomani = array ('Plant' => Array ('className' = & gt; 'Plant', 'JoinTable' => 'emp_plant', 'ForeignKey' = & Gt; 'Employee_ID', 'Association Leading' = & gt; 'LocationID', 'Unique' => True, 'Terms' =>, '',));   

Update : I tried to set a "Finder query" attribute to allow the table to join, but I do not know how to use a raw SQL Queries are given, such as allowing the dynamically use of IDs for the model's example rather than a predefined value.

I [Plant] Join [DB] from [Plant], from

  Selection]. [DBO]. [Emplant] AS [Emplant] on [[employee_id] = ** 4 ** and [amplant]. [ID] = [Plant]. [Location ID]]   

Give me the right data for an employee a , but I do not know how to make this finder dynamic query should be a way to work for it.

Try

  Var $ useDbConfig = 'optional';   

In your model class.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -