How do you perform a joins in CakePHP like for example the one below for MySQL?
SELECT *
FROM yarns y
JOIN yarn_brands yb
JOIN contents ct
WHERE y.id = ct.yarn_id
AND yb.id = y.yarn_brand_id
AND ct.material_id = 2
I have tried to search around for the answer but i dont find anything that works.
I found something about “contain”, i have tried this but i get the result that the query it produces doesent include a join of the table requested to join in.
$this->Message->find('all', array(
'contain' => array('User')
'conditions' => array(
'Message.to' => 4
),
'order' => 'Message.datetime DESC'
));
This is the join i ended up with: