Hi Marco,
 
thanks for the quick response. I assume that when a ORM is in the play (at 
least for me) a DDD approach is intended. When it comes to read performance I 
often hear not to go with the object graph but instead work with plain arrays. 
Probably the pattern which is meant beyond that recommendation is CQRS. Am I 
right? One thing which I did not yet grasp is how to deal with code duplication 
between read/write scenarios. E.g. there is a user entity which has a method 
getName() which returns “firstname + lastname”. I also want to use that method 
in read scenarios. How should I implement that as I do only have an array in 
the read scenario? Do I somewhere have to duplicate these “commonly” needed 
methods which obviously is not desired or which is the best approach for that?
 
Best Regards
Christian
 
Von: Marco Pivetta [mailto:[email protected]] 
Gesendet: Donnerstag, 27. Juni 2013 10:59
An: Christian Ebert
Cc: Zend Framework General
Betreff: Re: [fw-general] Re: How to use TableGateway, when output with nested 
lists needed?
 
@Christian so far, anybody (that I know of) trying to emulate that kind of 
structure in Zend\Db has moved to ORM.
What you can do is avoiding having direct references and keeping each aggregate 
root separate from the others and still linked via ID references (old style), 
which also works.


Marco Pivetta 

 <http://twitter.com/Ocramius> http://twitter.com/Ocramius      

 <http://ocramius.github.com/> http://ocramius.github.com/
 
On 27 June 2013 10:56, Christian Ebert < <mailto:[email protected]> 
[email protected]> wrote:
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: <mailto:[email protected]> [email protected]]
Gesendet: Donnerstag, 27. Juni 2013 00:03
An:  <mailto:[email protected]> [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>
 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:  <mailto:[email protected]> [email protected]
Info:  <http://framework.zend.com/archives> http://framework.zend.com/archives
Unsubscribe:  <mailto:[email protected]> 
[email protected]



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


 

Reply via email to