← Index
Performance Profile   « block view • line view • sub view »
For opac/opac-main.pl
  Run on Fri Jul 18 13:58:34 2008
Reported on Fri Jul 18 13:58:41 2008

File/usr/share/perl5/CGI/Session/Driver/mysql.pm
Statements Executed25
Total Time0.004075 seconds

Subroutines — ordered by inclusive time then name
CallsInclusive
Time
Subroutine
10.00356CGI::Session::Driver::mysql::store
10.00004CGI::Session::Driver::mysql::table_name
10.00003CGI::Session::Driver::mysql::init
00CGI::Session::Driver::mysql::BEGIN
00CGI::Session::Driver::mysql::_mk_dsnstr

LineStmts.Exclusive
Time
Avg.Code
1package CGI::Session::Driver::mysql;
2
3# $Id: mysql.pm 351 2006-11-24 14:16:50Z markstos $
4
530.000031e-05use strict;
# spent 0.00001s making 1 calls to strict::import
630.000030.00001use Carp;
# spent 0.00007s making 1 calls to Exporter::import
730.000450.00015use CGI::Session::Driver::DBI;
# spent 4e-06s making 1 calls to 1
8
912e-062e-06@CGI::Session::Driver::mysql::ISA = qw( CGI::Session::Driver::DBI );
10100$CGI::Session::Driver::mysql::VERSION = "4.20";
11
12sub _mk_dsnstr {
13 my ($class, $dsn) = @_;
14 unless ( $class && $dsn && ref($dsn) && (ref($dsn) eq 'HASH')) {
15 croak "_mk_dsnstr(): usage error";
16 }
17
18 my $dsnstr = $dsn->{DataSource};
19 if ( $dsn->{Socket} ) {
20 $dsnstr .= sprintf(";mysql_socket=%s", $dsn->{Socket});
21 }
22 if ( $dsn->{Host} ) {
23 $dsnstr .= sprintf(";host=%s", $dsn->{Host});
24 }
25 if ( $dsn->{Port} ) {
26 $dsnstr .= sprintf(";port=%s", $dsn->{Port});
27 }
28 return $dsnstr;
29}
30
31
32
# spent 0.00003s within CGI::Session::Driver::mysql::init which was called: # 1 times (0.00003s) by CGI::Session::Driver::new at line 24 of /usr/share/perl5/CGI/Session/Driver.pm
sub init {
3340.000024e-06 my $self = shift;
34 if ( $self->{DataSource} && ($self->{DataSource} !~ /^dbi:mysql/i) ) {
35 $self->{DataSource} = "dbi:mysql:database=" . $self->{DataSource};
36 }
37
38 if ( $self->{Socket} && $self->{DataSource} ) {
39 $self->{DataSource} .= ';mysql_socket=' . $self->{Socket};
40 }
41 return $self->SUPER::init();
# spent 0.00001s making 1 calls to CGI::Session::Driver::DBI::init
42}
43
44
# spent 0.00356s within CGI::Session::Driver::mysql::store which was called: # 1 times (0.00356s) by CGI::Session::flush at line 244 of /usr/share/perl5/CGI/Session.pm
sub store {
4560.003520.00059 my $self = shift;
46 my ($sid, $datastr) = @_;
47 croak "store(): usage error" unless $sid && $datastr;
48
49 my $dbh = $self->{Handle};
50 $dbh->do("REPLACE INTO " . $self->table_name . " (id, a_session) VALUES(?, ?)", undef, $sid, $datastr)
# spent 0.00350s making 1 calls to DBI::db::do # spent 0.00004s making 1 calls to CGI::Session::Driver::mysql::table_name
51 or return $self->set_error( "store(): \$dbh->do failed " . $dbh->errstr );
52 return 1;
53}
54
55
56# If the table name hasn't been defined yet, check this location for 3.x compatibility
57
# spent 0.00004s within CGI::Session::Driver::mysql::table_name which was called: # 1 times (0.00004s) by CGI::Session::Driver::mysql::store at line 50 of /usr/share/perl5/CGI/Session/Driver/mysql.pm
sub table_name {
5830.000026e-06 my $self = shift;
59 unless (defined $self->{TableName}) {
60 $self->{TableName} = $CGI::Session::MySQL::TABLE_NAME;
61 }
62 return $self->SUPER::table_name(@_);
# spent 0.00002s making 1 calls to CGI::Session::Driver::DBI::table_name
63}
64
6514e-064e-061;
66
67__END__;
68
69=pod
70
71=head1 NAME
72
73CGI::Session::Driver::mysql - CGI::Session driver for MySQL database
74
75=head1 SYNOPSIS
76
77 $s = new CGI::Session( "driver:mysql", $sid);
78 $s = new CGI::Session( "driver:mysql", $sid, { DataSource => 'dbi:mysql:test',
79 User => 'sherzodr',
80 Password => 'hello' });
81 $s = new CGI::Session( "driver:mysql", $sid, { Handle => $dbh } );
82
83=head1 DESCRIPTION
84
85B<mysql> stores session records in a MySQL table. For details see L<CGI::Session::Driver::DBI|CGI::Session::Driver::DBI>, its parent class.
86
87It's especially important for the MySQL driver that the session ID column be
88defined as a primary key, or at least "unique", like this:
89
90 CREATE TABLE sessions (
91 id CHAR(32) NOT NULL PRIMARY KEY,
92 a_session TEXT NOT NULL
93 );
94
95=head2 DRIVER ARGUMENTS
96
97B<mysql> driver supports all the arguments documented in L<CGI::Session::Driver::DBI|CGI::Session::Driver::DBI>. In addition, I<DataSource> argument can optionally leave leading "dbi:mysql:" string out:
98
99 $s = new CGI::Session( "driver:mysql", $sid, {DataSource=>'shopping_cart'});
100 # is the same as:
101 $s = new CGI::Session( "driver:mysql", $sid, {DataSource=>'dbi:mysql:shopping_cart'});
102
103=head2 BACKWARDS COMPATIBILITY
104
105For backwards compatibility, you can also set the table like this before calling C<new()>. However, it is not recommended because it can cause conflicts in a persistent environment.
106
107 $CGI::Session::MySQL::TABLE_NAME = 'my_sessions';
108
109=head1 LICENSING
110
111For support and licensing see L<CGI::Session|CGI::Session>.
112
113=cut