Hi,

this is an interesting question for me also. Are there any best practices
for not overly compley use cases for the hydration of entities with
associations on multiple levels or is the recommendation to use a ORM like
Doctrine 2?

Best Regards
Christian


-----Ursprüngliche Nachricht-----
Von: automatix [mailto:[email protected]] 
Gesendet: Donnerstag, 27. Juni 2013 00:03
An: [email protected]
Betreff: [fw-general] Re: How to use TableGateway, when output with nested
lists needed?

The code snippets have been filtered out... So, once again:

Hello!

I have an application, that is a bit more complex, that the Album
application from the docu, but the structure is very similar and it's also
using the combination of TableGateway and mapper classes to for every in the
model.

It works fine for "plain" objects like this:

{
   "data":{
      "id":"123",
      "title":"test title",
      "details":"test details"
   }
}

But now I need a complex object, that also can contain nesetd lists, e.g.:

{
    "data":{
        "id":"123",
        "title":"test title",
        "details":"test details",
        "events":{
            "count":"3",
            "events_list":[ <- main list
                {
                    "id":"987",
                    "date":"2013-07-20",
                    "place":"Berlin",
                    "trainers":{
                        "count":"1",
                        "trainers_teamid":"14",
                        "trainers_teamname":"Trainers Team Foo",
                        "trainers_list":[ <- nested list
                            {
                                "id":"135",
                                "name":"Tom"
                            }
                        ]
                    }
                },
                {
                    "id":"876",
                    "date":"2013-07-21",
                    "place":"New York",
                    "trainers":{
                        "count":"3",
                        "trainers_teamid":"25",
                        "trainers_teamname":"Trainers Team Bar",
                        "trainers_list":[ <- nested list
                            {
                                "id":"357",
                                "name":"Susan"
                            },
                            {
                                "id":"468",
                                "name":"Brian"
                            },
                            {
                                "id":"579",
                                "name":"Barbara"
                            }
                        ]
                    }
                },
                {
                    "id":"756",
                    "date":"2013-07-29",
                    "place":"Madrid",
                    "trainers":{
                        "count":"1",
                        "trainers_teamid":"36",
                        "trainers_teamname":"Trainers Team Baz",
                        "trainers_list":[ <- nested list
                            {
                                "id":"135",
                                "name":"Sandra"
                            }
                        ]
                    ]
                }
            ]
        }
    }
}

How / where should I assemble the data to this structure? Directly in the
mapper, so that it contains the whole multidimensional data? Or should I
handle this with multiple database requests anb assemple the structure in
the controller? Or should I use multiple mapper classes?

Thanks



--
View this message in context:
http://zend-framework-community.634137.n4.nabble.com/How-to-use-TableGateway
-when-output-with-nested-lists-needed-tp4660478p4660490.html
Sent from the Zend Framework mailing list archive at Nabble.com.

--
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]



--
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to