Hydrating a Relational Entity in Zend Framework 2

For programming and general questions on Zend Framework

Hydrating a Relational Entity in Zend Framework 2

Postby augu7384 on Wed Sep 21, 2016 1:31 pm

Im working in a project that i have a common situation, like Order-Items, i know that the TableGateway Pattern is totally different from ORM pattern but my project is old and i can change that, im managing the entities totally separated, like:

(Class Order) ------ (Class Item)

what i want is do someting like:

(Class Order)
propriety A
propriety B
propriety C
propriety D
propriety E
propriety Itens => Array(
.............................[0]=>Item Object A()
.............................[1]=>Item Object B()
.............................[2]=>Item Object C()
)

but i want to do that with only one Method like 'findOrderById' and that returns me a relational one-to-many entity like above, im using HydrateResultSet.
augu7384
 
Posts: 1
Joined: Wed Sep 21, 2016 1:25 pm

Re: Hydrating a Relational Entity in Zend Framework 2

Postby mehm8471 on Tue Jan 03, 2017 11:07 am

You need to create your custom Hydrator and set up order items by injecting the item mapper into the hydrator.

It is simple to say what to do as I've been there but explaining how to do take some time and absolutely cannot be done in a forum post. However, I planned to write a blog post about it in my website under the existing "Online Book Catalog Application Tutorial" series but it is currently at the Mapper step and there are 2 posts before Hydrator step.
mehm8471
 
Posts: 22
Joined: Sat Jun 21, 2014 11:39 pm

Re: Hydrating a Relational Entity in Zend Framework 2

Postby dhar9669 on Mon Jan 16, 2017 1:50 pm

It is required to create custom Hydrator for Order and order items and make the relation accordingly.
Hope it will help.
dhar9669
 
Posts: 5
Joined: Fri Jan 13, 2017 2:58 pm


Return to Zend Framework

Who is online

Users browsing this forum: No registered users and 2 guests