Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Search for ORM with Multi-Table-Object Support

by tospo (Hermit)
on May 03, 2012 at 06:41 UTC ( #968650=note: print w/ replies, xml ) Need Help??


in reply to Search for ORM with Multi-Table-Object Support

++ for DBIC
I'm using it in my current project and I also have to build multi-table objects. These are quite large objects in my case with quite a lot of data, so it is split up across tables and I only need to assemble the full object when a single record is selected.
I just have a 'to_xxx_object' method in the result class for the table that stores the bulk of the data, which just gathers all the data from the related result classes and instantiates the big object. You end up with a single place in your code that needs to change if the tables change.


Comment on Re: Search for ORM with Multi-Table-Object Support
Re^2: Search for ORM with Multi-Table-Object Support
by Xel (Novice) on May 03, 2012 at 07:19 UTC

    Hey - that sounds like a solution. And like nearly the same use-case as mine.

    As I understand you, this can even be insertable/updateable - just write back any changes to the related objects and save them back to the database.

    Thank you very much - I will try it out.

      hmm, my post got lost, anyway, I was just saying that you can definitely do that.
      You will want to provide a 'insert_xxx_object' method that knows how your object has to be broken up and issues all the create->()->create_related() calls to write them to the database. This one would go into a ResulSet class for your 'main' table (or any one of the tables that are involved in storing this object), which you may have to create first.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://968650]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (11)
As of 2014-10-24 12:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (131 votes), past polls