The CakePHP 2.0 documentation says the following:
In CakePHP some associations (belongsTo and hasOne) performs automatic joins to retrieve data, so you can issue queries to retrieve models based on data in the related one.
But this is not the case with hasMany and hasAndBelongsToMany associations. Here is where forcing joins comes to the rescue. You only have to define the necessary joins to combine tables and get the desired results for your query.
But I'm seeing different behavior in two ways:
All my hasAndBelongsToMany associations are joined automatically (unless I tell them not to using
$options['contain']=...
when I search.In one situation, I CAN'T get a hasMany association to appear unless I force it with
$options['joins']=...
The latter problem may be something I've done wrong, but it's difficult to troubleshoot without knowing how it SHOULD work. I suspect that the documentation is either inaccurate on this point, or perhaps it works completely differently when the containable component is in use. (NOTE: We have public $actsAs = array('Containable');
in our AppModel so all models inherit it.)