23377 Posts in 18296 Topics by 2867 members
|Go to End|
23 August 2012 at 8:19pm
Encountered an issue with using the ORM in Silverstripe 3.
I have a DataObject OrderItem, and Deal inherits from OrderItem. Deal has a has_one Mechanic (Member).
The issue arises when I try to use the filter function
$deals = Deal::get()->filter(array(
"Mechanic.SuburbID:ExactMatch" => $suburb
It gives an error on DataList->Count. The issue appears to be that it joins on the Mechanic (Member table) before it joins on the Deal table.
I am able to get around the issue by explicitly joining the Deal table with ->leftJoin before calling filter.
Also, I've found the relations only seem to work when you use a search filter with them, e.g. "Mechanic.SuburbID:ExactMatch" => $suburb works but "Mechanic.SuburbID" => $suburb doesn't.
|Go to Top|