Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Web Logs Using DBI

by btrott (Parson)
on Apr 14, 2000 at 10:38 UTC ( #7598=perltutorial: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
        PerlLogHandler Foo::DBILogger
    
  2. or download this
        create table log (
        stamp datetime not null,
    ...
        status smallint(3),
        bytes int(8)
        );
    
  3. or download this
        package Foo::DBILogger;
    
    ...
        use DBI;
        use POSIX 'strftime';
        use Apache::Constants qw/OK/;
    
  4. or download this
        sub handler {
            my $r = shift;
    
  5. or download this
            my $dbh = DBI->connect('dsn', 'user', 'password', 'mysql',
                { RaiseError => 1 })
    ...
    (stamp, host, method, url, user, browser, referer, status, bytes)
    values (?, ?, ?, ?, ?, ?, ?, ?, ?)
    SQL
    
  6. or download this
            $sth->execute(
                strftime("%Y-%m-%d %H:%M:%S", localtime),
    ...
                $r->bytes_sent
            );
            $sth->finish;
    
  7. or download this
            return OK;
        }
     
        1;
    
  8. or download this
        package Foo::DBILogger;
    
    ...
        }
     
        1;
    
  9. or download this
        select host, url
        from log
        where to_days(now()) - to_days(stamp) <= 1;
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perltutorial [id://7598]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2014-07-10 03:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (198 votes), past polls