@DavidZB
There is no way to get information from the join tables in DataMapper, currently. You need to use a third Object to store the information, like this:
bugs, priorities stay the same.
prioritydates
fields: id, date
has_one: priority, bug
bugs_prioritydates
id, bug_id, prioritydate_id
priorities_prioritydates
id, priority_id, prioritydate_id
$bug = ...
$pds = $bug->prioritydate->where("date >=", $date1)->where("date <=", $date2)->get();
foreach($pds->all as $pd) {
$date = $pd->date;
$priority = $pd->priority->get();
}
Now, in the current implementation, you have to use the extra join tables, which is rather ugly, and makes certain complex queries difficult. I have been working on a version that (among other things) allows has_ones to use traditional, in-table fields. You can try it out a few pages back, it is almost a drop-in replacement for the official version. If you use that, then you can drop the join tables, and just make your prioritydate table:
id, date, priority_id, bug_id
And with the testing version, you can run a query like this:
$bug = ...
$pds = new PriorityDate();
$pds->where_related($bug)
$pds->join_related('priority', array("id","name",etc…));
$pds->get();
foreach($pds->all as $pd) {
echo("On {$pd->date}, the priority was {$pd->priority_name}");
}
The testing code is definitely experimental, however, so you might not want to use it in a production system yet.