Reportero updates.
[reportero_perl.git] / reportero
blob9d75b639a2e41468fdceb6bc0e22fcd74dc17618
1 #!/bin/env perl
2 # Test reporting program
4 use warnings;
5 use DBI;
6 use CGI qw(:standard);
7 use CGI::Carp qw(fatalsToBrowser);
10 $db_name = "tarificador";
11 $db_user = "tarificador";
12 $db_passwd = "n3ur0d3s4rr0ll008";
14 sub
15 db_search
17   my $dbh = shift ;
18 #my $sql = param('date');
19 #my $sql = "SELECT * from llamada where fecha_hora = day('4/3/2008')";
21   my $sql = param('query');
24   my $sth = $dbh->prepare("$sql");
25   $sth->execute();
27   print <<'  END'
28     <html>
29     <head></head>
30     <body>
31   END
32   ;
34   my $count;
35   while (my $hash = $sth->fetchrow_hashref)
36   {
37     print 
38       "$hash->{id},$hash->{fecha_hora},$hash->{origen},$hash->{destino}<br/>";
39     print map{ "$_ "} values %$hash;
40     $count++;
41   }
43   print <<'  END'
44     </body>
45     </html>
46   END
47   ;
50 my $dbh = DBI->connect("dbi:mysql:dbname=$db_name"
51     , "$db_user", "$db_passwd")
52     or die "ERROR: Cannot connect to DB: $DBI::errstr!\n";
54 print header();
56 db_search($dbh);