I need to access all words belonging to sentences, and ALSO list all sentences that contain a given word. (this is not the real example, but it's as close as I can come and explain easily). A has many_many and belongs_many_many seems the right choice, but the accessor does not work from the 'belongs_many_many side. It seems like it should be easy, but I must be missing something. Any help?
class Sentence extends DataObject {
....
static $many_many = array( 'Words' => 'Word');
function getMyWords() {
return $this->getManyManyComponents('Words'); //This works great!
}
....
}
class Word extends DataObject {
....
static $belongs_many= array('Sentences' => 'Sentence');
...
function getMySentances() {
return $this -> getManyManyComponents('Sentences'); // This does not work. What to do? Can it be done?
}
...
}