I have two tables with a field usernamein both. How can I specify a field name for a local and external table?
I want CakePHP to do something like
ON (`T1`.`username` = `T2`.`username`)`
as a result. Without any changes, the tables will be joined with the following condition:
ON (`T1`.`id` = `T2`.`t1_id`)`
Setting a property is 'foreign_key' = 'username'not enough because it raises a request like this:
ON (`t1`.`id` = `t2`.`username`)`
I have two solutions. The first uses the join property and joins the table on the fly. In this case, I can set both the local and the external field. But if I need to join more tables with this manually linked one, I can no longer use contain. I need to write the following joins manually, even if these associations were set correctly. So I need to write long connection definitions every time, instead just use'contain' => array('T1', 'T2', 'T3')
"primary_key" . . , "" 'id'.
- , , .
, , - , , CakePHP . , , - . , , 'foreign_key' .