Jump to:

23377 Posts in 18296 Topics by 2867 members

General Questions

SilverStripe Forums » General Questions » Join order on Datalist Count

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 426 Views
  • riddler
    Avatar
    Community Member
    2 Posts

    Join order on Datalist Count Link to this post

    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.

    426 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.