Hello
I have a Mysqldatabase which I store "event data" for an application. In this case I have to use PERL because the application is made using PERL, another guy has already started but Im having seriosly problems knowing what he has done so I would really be glad if anyone could help me clearing some questions out!
Lets say my Mysql database has 5 columns:
id usrid date_from interval_nr event_cnt
----------------------------------------------
1 2 2005-04-04 2 1
2 2 2005-04-04 3 6
3 2 2005-04-04 3 1
.
----------------------------------------------
Now all rows are fetched using SELECT * FROM mytable into a hashtable using syntax below
.
.
Some declaration (prepare select execute)
.
while ($row = $sth->fetchrow_hashref ()) {
foreach $key (keys %$row) { $res{$row->{usr_id}}{$row->{date_from}}{$row->{interval_nr}}{$key}=$row->{$key};
}
}
.
What is he doing(?)... what I understand with my little knowledge he stores the values in a multidimensonal hash that has its keys %res{some queuenr}{some date}{some intervalnr}....but is the hashvalue all other rows or?
lets saya I want to summerize all elements by value "event_cnt" ("event_cnt" is a column name in my Mysql-table) how do I do that? I have been trying to do as below but then I get an "Use of uninitialized value" for values in my hashtable.
@datefrom=("2005-10-19 00:00:00","2005-10-20 00:00:00");
@usrid=(478,14,594,53,52,392,595,759);
foreach $que (@usrid) {
foreach $date_from (@datefrom){
foreach $interval (0..95) {
$tot{'income_cnt'}{$que} += $res{$que}{$date_from}{$interval}{'event_cnt'};
}
}
print $tot{'income_cnt'}{$que}." ".$tot{'lostcalls'}{$que}."\n";
}
I hope you understand what I mean..
Regards/D_S
Then I create a multidimensopnale hash (%res) that has
I have a Mysqldatabase which I store "event data" for an application. In this case I have to use PERL because the application is made using PERL, another guy has already started but Im having seriosly problems knowing what he has done so I would really be glad if anyone could help me clearing some questions out!
Lets say my Mysql database has 5 columns:
id usrid date_from interval_nr event_cnt
----------------------------------------------
1 2 2005-04-04 2 1
2 2 2005-04-04 3 6
3 2 2005-04-04 3 1
.
----------------------------------------------
Now all rows are fetched using SELECT * FROM mytable into a hashtable using syntax below
.
.
Some declaration (prepare select execute)
.
while ($row = $sth->fetchrow_hashref ()) {
foreach $key (keys %$row) { $res{$row->{usr_id}}{$row->{date_from}}{$row->{interval_nr}}{$key}=$row->{$key};
}
}
.
What is he doing(?)... what I understand with my little knowledge he stores the values in a multidimensonal hash that has its keys %res{some queuenr}{some date}{some intervalnr}....but is the hashvalue all other rows or?
lets saya I want to summerize all elements by value "event_cnt" ("event_cnt" is a column name in my Mysql-table) how do I do that? I have been trying to do as below but then I get an "Use of uninitialized value" for values in my hashtable.
@datefrom=("2005-10-19 00:00:00","2005-10-20 00:00:00");
@usrid=(478,14,594,53,52,392,595,759);
foreach $que (@usrid) {
foreach $date_from (@datefrom){
foreach $interval (0..95) {
$tot{'income_cnt'}{$que} += $res{$que}{$date_from}{$interval}{'event_cnt'};
}
}
print $tot{'income_cnt'}{$que}." ".$tot{'lostcalls'}{$que}."\n";
}
I hope you understand what I mean..
Regards/D_S
Then I create a multidimensopnale hash (%res) that has