7912 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » How to return only one value from Dataobject if data in different data sets are indentical
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: | 370 Views |
-
How to return only one value from Dataobject if data in different data sets are indentical

27 August 2012 at 10:10am
Hi there,
hope I can explain my problem clearly. Okay, I will try..
I have created a dataobject with data sets like this:1. data set: name1 - adress1 - town1
2. data set: name2 - adress2 - town1
3. data set: name3 - adress3 - town2
4. data set: name4 - adress4 - town2
3. data set: name5 - adress5 - town3You can see that different people are living in different towns.
Now I would like to know in which different towns the people are living.
The desired result should be: town1, town2 and town3
Any ideas? Thanks everybody for support,
Lars
-
Re: How to return only one value from Dataobject if data in different data sets are indentical

27 August 2012 at 11:40am
If you start with a GROUP BY sql statement:
$sql = singleton('SomeObject')->buildSQL();
$sql->select[] = "town";
$result = $sql->groupby("town")->execute();And then pass the result into a dataobject you can use:
$groupObject = singleton('SomeObject')->buildDataObjectSet($result);
Just return $groupObject and you can use it in your template.
-
Re: How to return only one value from Dataobject if data in different data sets are indentical

27 August 2012 at 10:32pm
Hi SparkGreen,
thank you so much. Your job works perfectly!
Best regards,LarsE
| 370 Views | ||
|
Page:
1
|
Go to Top |


