21287 Posts in 5733 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 193 Views |
-
Join order on Datalist Count

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.
| 193 Views | ||
|
Page:
1
|
Go to Top |

