line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CGI::Session::Driver::odbc; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
21042
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
41
|
|
4
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
97
|
|
5
|
1
|
|
|
1
|
|
1016
|
use CGI::Session::Driver::DBI; |
|
1
|
|
|
|
|
26259
|
|
|
1
|
|
|
|
|
823
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
@CGI::Session::Driver::odbc::ISA = qw( CGI::Session::Driver::DBI ); |
8
|
|
|
|
|
|
|
$CGI::Session::Driver::odbc::VERSION = '1.05'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# ----------------------------------------------- |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub init |
13
|
|
|
|
|
|
|
{ |
14
|
0
|
|
|
0
|
1
|
|
my($self) = @_; |
15
|
|
|
|
|
|
|
|
16
|
0
|
0
|
0
|
|
|
|
if ($$self{'DataSource'} && ($$self{'DataSource'} !~ /^dbi:ODBC/) ) |
17
|
|
|
|
|
|
|
{ |
18
|
0
|
|
|
|
|
|
$$self{'DataSource'} = "dbi:ODBC:$$self{'DataSource'}"; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
return $self -> SUPER::init(); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
} # End of init. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# ----------------------------------------------- |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub store |
28
|
|
|
|
|
|
|
{ |
29
|
0
|
|
|
0
|
1
|
|
my($self, $sid, $datastr) = @_; |
30
|
|
|
|
|
|
|
|
31
|
0
|
0
|
0
|
|
|
|
Carp::croak "store(): usage error" if (! ($sid && $datastr) ); |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
my($dbh) = $$self{'Handle'}; |
34
|
0
|
|
|
|
|
|
my($sth) = $dbh -> prepare("select $self->{IdColName} from " . $self -> table_name() . ' where id=?'); |
35
|
|
|
|
|
|
|
|
36
|
0
|
0
|
|
|
|
|
if (! defined $sth) |
37
|
|
|
|
|
|
|
{ |
38
|
0
|
|
|
|
|
|
return $self -> set_error("store(): \$sth->prepare failed with message " . $dbh -> errstr() ); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
0
|
0
|
|
|
|
|
$sth -> execute($sid) or return $self -> set_error("store(): \$sth->execute failed with message " . $dbh->errstr() ); |
42
|
|
|
|
|
|
|
|
43
|
0
|
0
|
|
|
|
|
if ($sth->fetchrow_array() ) |
44
|
|
|
|
|
|
|
{ |
45
|
0
|
0
|
|
|
|
|
_run_sql($dbh, 'update ' . $self -> table_name() . " set $self->{DataColName}=? where $self->{IdColName}=?", $datastr, $sid) |
46
|
|
|
|
|
|
|
or return $self -> set_error("store(): serialize to db failed " . $dbh->errstr() ); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
else |
49
|
|
|
|
|
|
|
{ |
50
|
0
|
0
|
|
|
|
|
_run_sql($dbh, 'insert into ' . $self -> table_name() . " ($self->{DataColName}, $self->{IdColName}) values(?, ?)", $datastr, $sid) |
51
|
|
|
|
|
|
|
or return $self -> set_error("store(): serialize to db failed " . $dbh->errstr() ); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
return 1; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} # End of store. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# ----------------------------------------------- |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub _run_sql |
61
|
|
|
|
|
|
|
{ |
62
|
0
|
|
|
0
|
|
|
my($dbh, $sql, $datastr, $sid) = @_; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
eval |
65
|
0
|
|
|
|
|
|
{ |
66
|
0
|
0
|
|
|
|
|
my($sth) = $dbh -> prepare($sql) or return 0; |
67
|
|
|
|
|
|
|
|
68
|
0
|
0
|
|
|
|
|
$sth -> bind_param(1, $datastr) or return 0; |
69
|
0
|
0
|
|
|
|
|
$sth -> bind_param(2, $sid) or return 0; |
70
|
0
|
0
|
|
|
|
|
$sth -> execute() or return 0; |
71
|
|
|
|
|
|
|
}; |
72
|
|
|
|
|
|
|
|
73
|
0
|
0
|
|
|
|
|
return 0 if $@; |
74
|
0
|
|
|
|
|
|
return 1; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
} # End of _run_sql. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# ----------------------------------------------- |
79
|
|
|
|
|
|
|
# If the table name hasn't been defined yet, check this location for 3.x compatibility. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub table_name |
82
|
|
|
|
|
|
|
{ |
83
|
0
|
|
|
0
|
0
|
|
my($self) = shift; |
84
|
|
|
|
|
|
|
|
85
|
0
|
0
|
|
|
|
|
if (! defined $$self{'TableName'}) |
86
|
|
|
|
|
|
|
{ |
87
|
0
|
|
|
|
|
|
$$self{'TableName'} = $CGI::Session::ODBC::TABLE_NAME; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
return $self -> SUPER::table_name(@_); |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
} # End of table_name. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# ----------------------------------------------- |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
__END__ |