Jump to:

7937 Posts in 1537 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » GROUP BY in DataObject::get

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 2681 Views
  • sca123
    Avatar
    Community Member
    61 Posts

    GROUP BY in DataObject::get Link to this post

    Hi
    Where do I put a GROUP BY statement into the DataObject:get?

    I currently have:

    return DataObject::get("Specification","Director::currentPage()->ID."=PageID","OutputPower)","","");

    Thanks in advance.

  • UncleCheese
    Avatar
    4085 Posts

    Re: GROUP BY in DataObject::get Link to this post

    That's not really what DataObject::get() is designed to do. Just use a SQLQuery() object.

    $sql = singleton('SomeObject')->getExtendedSQL();
    $sql->select[] = "SUM(SomeField) AS Total";
    $result = $sql->where("Foo = 'Bar'")
    ->innerJoin("JoinTable", "`JoinTable`.ID = `AnotherTable`.ID")
    ->groupby("1")
    ->having("Foo > 3")
    ->execute();

  • Graphicator
    Avatar
    Community Member
    62 Posts

    Re: GROUP BY in DataObject::get Link to this post

    I may have followed upon the original question here http://bit.ly/n5y3du

    2681 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.