Views and to-many relationship (in service output)

Hi experts!
I have a Drupal installation (newest of 6 branch) with cck, views and service modules installed.
I'm building a application with a drupal backend and a Flex client. So I want to exchange data. Everythings works fine except one thing:

The service output of to-many relations is weird. I have 2 content types: Artist and Video. Each video can have 1 or more related Artists.
I have 2 artists and two videos. the second video has BOTH artsts attached.

Video1 (nid: 10)
 - Artist 1
Video 2 (nid: 12)
 - Artist 1
 - Artist 2

The result looks like this:

Array
(
    [0] => stdClass Object
        (
            [nid] => 10
            [node_title] => Interview with Metallica
            [node_node_data_field_related_artists_node_data_field_artist_name_field_artist_name_value] => Metallica
            [node_node_data_field_related_artists_nid] => 9
            [node_node_data_field_related_artists_type] => artist
            [node_node_data_field_related_artists_vid] => 9
            [node_node_data_field_related_artists_node_data_field_artist_name_field_artist_genre_value] => Thrash Metal
            [node_node_data_field_related_artists_title] => Metallica - Biggest Metal Band ever
        )

    [1] => stdClass Object
        (
            [nid] => 12
            [node_title] => Mixed Interview
            [node_node_data_field_related_artists_node_data_field_artist_name_field_artist_name_value] => Slipknot
            [node_node_data_field_related_artists_nid] => 11
            [node_node_data_field_related_artists_type] => artist
            [node_node_data_field_related_artists_vid] => 11
            [node_node_data_field_related_artists_node_data_field_artist_name_field_artist_genre_value] => NuMetal
            [node_node_data_field_related_artists_title] => Chaos Metal Head from Iowa
        )

    [2] => stdClass Object
        (
            [nid] => 12
            [node_title] => Mixed Interview
            [node_node_data_field_related_artists_node_data_field_artist_name_field_artist_name_value] => Metallica
            [node_node_data_field_related_artists_nid] => 9
            [node_node_data_field_related_artists_type] => artist
            [node_node_data_field_related_artists_vid] => 9
            [node_node_data_field_related_artists_node_data_field_artist_name_field_artist_genre_value] => Thrash Metal
            [node_node_data_field_related_artists_title] => Metallica - Biggest Metal Band ever
        )

)

Open in new window


The "nid" of the second and third entry is the same.
I want just 2 items in the array. The second one should have an array with all related artists.

Is that related to the delta settings? I didn't find detailed information on "delta". But playing around with it doesn't solve my issue. Then only one of the two artists is included. That sucks. What I'm I doing wrong?

Thanks in advance!
Simon
simonwidjajaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Thomas4019Commented:
It's a known problem, when you setup anview with a many to one relationship where the delta is set to "all", duplicates appear. What happens is each value in the many to one relationship creates a new row. Looking at your screenshot, I see the nid 12 is included twice. You could probably manually join the on the flex end. Or google views duplicates to see others solutions. Here's one related thread, http://drupal.org/project/dhtml_menu.
0
simonwidjajaAuthor Commented:
so there is NO solution?

I don't get the link you posted. Where is the connection between Views and DHTML?
0
Thomas4019Commented:
wow my bad, this is the link I meant to send, http://groups.drupal.org/node/72553#comment-272429.

pretty much there is no great solution, yes. People moan about the views duplicates problem over and over again and find a few workarounds but there is no one great solution. If you click on your relationship in views, under delta you will see this message ,

"The delta allows you to select which item in a multiple value field to key the relationship off of. Select "1" to use the first item, "2" for the second item, and so on. If you select "All", each item in the field will create a new row, which may appear to cause duplicates."

The best solution is probably to merge the multiple rows back into one within flex.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Drupal

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.