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, Ed, biapar, Willr, Ingo, swaiba

How to return only one value from Dataobject if data in different data sets are indentical

Go to End

3 Posts   1195 Views

Die Medien-Spezialisten

Community Member, 8 Posts

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 - town3

You 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,



Community Member, 6 Posts

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.

Die Medien-Spezialisten

Community Member, 8 Posts

27 August 2012 at 10:32pm

Hi SparkGreen,

thank you so much. Your job works perfectly!
Best regards,