Hello Monks,
For the last couple of months I have been trying to understand the Class::DBI module.
Slowly I've started to use it in some of my projects. The problem I'm having is
learning the finer points of the module. For example, lets say I have a database
with two tables. The first table Areas has a has_many relationship with the Stats
table. Now for the project I want to create a report with all the stats organized
by Areas. So the code would look something like:
my @areas = Areas->retrieve_all;
foreach my $area (@areas) {
print $area->name.":\n";
foreach my $stat ($area->stats) {
print "\t".join ",", ($stat->name,$stat->disk,$stat->m
+onth)."\n";
}
}
This would print out something like:
IT:
Robert,200mb,8
Lewis,100mb,5
Well thats all fine and good unless I want only the stats from August(8).
I'm not sure how to do this without grabing all the stats for an area then using
something like grep to get only the stats I want. I'm sure there is a better way to
do it, but I'm just not seeing it.
Any help would be great.
rlb3
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.