Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Web Logs Using DBI

by btrott (Parson)
on Apr 14, 2000 at 10:38 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: perltutorial [id://7598]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2024-04-18 17:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found