I'm trying to join a table (Connections) twice from another table (Ports).
The conditions are:
- One port can have one or no connection
- One connection has one from-port and one to-port
The structure is:
Table Ports:
- id
- number
Table Connections:
- id
- port_from_id
- port_to_id
- name
So now I want to join from Ports to Connections.
Cake always gives me this:
LEFT JOIN connections Connections ON Ports.id = (Connections.port_from_id)
But it has to be:
LEFT JOIN connections Connections ON Ports.id = (Connections.port_from_id) OR Ports.id = (Connections.port_to_id)
or something equivalent.
My Ports-Model actually looks like this:
$this->hasOne('Connections', [
'foreignKey' => 'port_from_id',
'joinType' => 'LEFT'
]);
How can I get the OR-Condition in my join?
Thanks!