You are looking for the through
parameter, have a look at the docs.
You need an extra table that stores the ids of both models
table users_locations
, fields: user_id
and location_id
(both indexed, of course)
And in your model:
protected $_has_many = array(
'users' => array(
'model' => 'user'
'through' => 'users_locations',
),
);
And vice versa in the user model:
protected $_has_many = array(
'locations' => array(
'model' => 'location'
'through' => 'users_locations',
),
);