Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: store/retrieve data structure in MySQL

by hakkr (Chaplain)
on Aug 01, 2005 at 15:37 UTC ( #479936=note: print w/replies, xml ) Need Help??


in reply to Re: store/retrieve data structure in MySQL
in thread store/retrieve data structure in MySQL

Note, it can be a bad idea to do this, instead of having a proper db design.

I have seen a coworker just use Data::Dumper to store text repsentations of objects. He then ends up using Regexp queries to search within db fields for object attributes. So he is storing more information than required and losing many rdbms features.

Tying your data to your dev language is obviously not a great idea for portability either. Anyway you dump it ,then you eval it as pseudo below. You will probably have to use a string rather than binary representation if you wish to search the data easily. As you are using a blob field you will have to use storable instead.

#get string representation for insert into db my $data={}; use Data::Dumper; my $serial=Dumper($data); #get object back from string my $obj=eval $serial;

Replies are listed 'Best First'.
Re^3: store/retrieve data structure in MySQL
by BarMeister (Beadle) on Aug 01, 2005 at 20:23 UTC
    I store all the properties of the object within the database in a nice normalized structure....this was only needed for use within a summary table for optimization reasons. I build the objects rarely so why not cache them? :-)

    Thanks everyone for the help.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://479936]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2017-12-17 09:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (462 votes). Check out past polls.

    Notices?