Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

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?

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2023-02-08 07:43 GMT
Find Nodes?
    Voting Booth?
    I prefer not to run the latest version of Perl because:

    Results (40 votes). Check out past polls.