Gentlemonks,
I am thinking about an Entity Bean package. I'm sure someone has written a CPAN module for this already. Something not unlike Tie::DBI, or actually more like Class::DBI.
What am I thinking of? A package that streamlines the creation of objects from rows in a database.
For example, I'm managing a configuration table... call it CONFIG. It has columns like this:
location_id (primary key)
local_dir
file_pattern
count_method
log_level
production
destinations
archive
So, I'm writing a Perl package that accepts a database handle and a primary key, queries the db, and populates its fields appropriately, when I got to idly thinking that all this should already be done for me. But where? And how?
Perl isn't magic. Any package that automated this kind of process would still have to know what columns to query and where to put them. Or perhaps I'm thinking about it backwards. The target class has a table name and a list of column names, and feeds them to the automation package -- which could have the database handle. Fine. Then perhaps it also has a place to store the data once retrieved. Well, of course it does: the class has access methods. So how about I name those methods the same as the column names... ok. Then the automation package does a SELECT, then calls the target class' methods to load the column values in.
Surely this kind of thing has already been done. So does anyone know the name of the package? I must be overlooking something obvious (like tie, or something).
Thanks,
Rob
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.