Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

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

GROUP BY in DataObject::get


Reply

3 Posts   2760 Views

Avatar
sca123

14 September 2010 at 4:46am Community Member, 61 Posts

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.

Avatar
UncleCheese

14 September 2010 at 5:03am 4085 Posts

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();

Avatar
Graphicator

17 September 2011 at 1:19pm Community Member, 62 Posts

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