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