I’m working in cakephp 3.3. I have two tables, let’s say they’re called
Products have an
id, and may have a
tag or both, or neither
Events have an id
, timestamp, and may have either a
name or a
tag, both or neither.
I want to get each event along with the product associated with that event. In EventsTable.php I can do this:
$this->hasOne('Products',[ 'foreignKey' => 'name', 'bindingKey' => 'product_name' ]);
and I can do this:
$this->hasOne('Products',[ 'foreignKey' => 'tag', 'bindingKey' => 'product_tag' ]);
But what I’d like is to use
tag, and if it’s not present, use
name. Is this possible?