7911 Posts in 1354 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » GROUP BY in DataObject::get
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 1937 Views |
-
GROUP BY in DataObject::get

14 September 2010 at 4:46am
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.
-
Re: GROUP BY in DataObject::get

14 September 2010 at 5:03am
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(); -
Re: GROUP BY in DataObject::get

17 September 2011 at 1:19pm
I may have followed upon the original question here http://bit.ly/n5y3du
| 1937 Views | ||
|
Page:
1
|
Go to Top |


