3 |
# $Id$ |
# $Id$ |
4 |
# |
# |
5 |
# $Log$ |
# $Log$ |
6 |
|
# Revision 1.9 2002/12/05 07:58:20 joko |
7 |
|
# + now using Tie::SecureHash as a base for the COREHANDLE |
8 |
|
# + former public COREHANDLE becomes private _COREHANDLE now |
9 |
|
# |
10 |
# Revision 1.8 2002/12/01 22:20:43 joko |
# Revision 1.8 2002/12/01 22:20:43 joko |
11 |
# + sub createDb (from Storage.pm) |
# + sub createDb (from Storage.pm) |
12 |
# |
# |
78 |
#use Data::Dumper; print Dumper($self->{dbi}); |
#use Data::Dumper; print Dumper($self->{dbi}); |
79 |
|
|
80 |
eval { |
eval { |
81 |
$self->{COREHANDLE} = DBI->connect( $dsn, '', '', $self->{locator}->{dbi} ); |
$self->{_COREHANDLE} = DBI->connect( $dsn, '', '', $self->{locator}->{dbi} ); |
82 |
if (!$self->{COREHANDLE}) { |
if (!$self->{_COREHANDLE}) { |
83 |
$logger->warning( __PACKAGE__ . "->connect failed: " . DBI::errstr ); |
$logger->warning( __PACKAGE__ . "->connect failed: " . DBI::errstr ); |
84 |
return; |
return; |
85 |
} |
} |
101 |
|
|
102 |
$logger->debug( __PACKAGE__ . "->configureCOREHANDLE" ); |
$logger->debug( __PACKAGE__ . "->configureCOREHANDLE" ); |
103 |
|
|
104 |
return if !$self->{COREHANDLE}; |
return if !$self->{_COREHANDLE}; |
105 |
|
|
106 |
# apply configured modifications to DBI-handle |
# apply configured modifications to DBI-handle |
107 |
if (exists $self->{locator}->{dbi}->{trace_level} && exists $self->{locator}->{dbi}->{trace_file}) { |
if (exists $self->{locator}->{dbi}->{trace_level} && exists $self->{locator}->{dbi}->{trace_file}) { |
108 |
$self->{COREHANDLE}->trace($self->{locator}->{dbi}->{trace_level}, $self->{locator}->{dbi}->{trace_file}); |
$self->{_COREHANDLE}->trace($self->{locator}->{dbi}->{trace_level}, $self->{locator}->{dbi}->{trace_file}); |
109 |
} |
} |
110 |
if (exists $self->{locator}->{dbi}->{RaiseError}) { |
if (exists $self->{locator}->{dbi}->{RaiseError}) { |
111 |
$self->{COREHANDLE}->{RaiseError} = $self->{locator}->{dbi}->{RaiseError}; |
$self->{_COREHANDLE}->{RaiseError} = $self->{locator}->{dbi}->{RaiseError}; |
112 |
} |
} |
113 |
if (exists $self->{locator}->{dbi}->{PrintError}) { |
if (exists $self->{locator}->{dbi}->{PrintError}) { |
114 |
$self->{COREHANDLE}->{PrintError} = $self->{locator}->{dbi}->{PrintError}; |
$self->{_COREHANDLE}->{PrintError} = $self->{locator}->{dbi}->{PrintError}; |
115 |
} |
} |
116 |
if (exists $self->{locator}->{dbi}->{HandleError}) { |
if (exists $self->{locator}->{dbi}->{HandleError}) { |
117 |
$self->{COREHANDLE}->{HandleError} = $self->{locator}->{dbi}->{HandleError}; |
$self->{_COREHANDLE}->{HandleError} = $self->{locator}->{dbi}->{HandleError}; |
118 |
} |
} |
119 |
|
|
120 |
} |
} |
125 |
|
|
126 |
# two-level handling for implicit connect: |
# two-level handling for implicit connect: |
127 |
# if there's no corehandle ... |
# if there's no corehandle ... |
128 |
if (!$self->{COREHANDLE}) { |
if (!$self->{_COREHANDLE}) { |
129 |
# ... try to connect, but ... |
# ... try to connect, but ... |
130 |
$self->connect(); |
$self->connect(); |
131 |
# ... if this still fails, there's something wrong probably, so we won't continue |
# ... if this still fails, there's something wrong probably, so we won't continue |
132 |
if (!$self->{COREHANDLE}) { |
if (!$self->{_COREHANDLE}) { |
133 |
return; |
return; |
134 |
} |
} |
135 |
} |
} |
136 |
|
|
137 |
#print "prepare sql: $sql\n"; |
#print "prepare sql: $sql\n"; |
138 |
|
|
139 |
my $sth = $self->{COREHANDLE}->prepare($sql); |
my $sth = $self->{_COREHANDLE}->prepare($sql); |
140 |
$sth->execute(); |
$sth->execute(); |
141 |
return $sth; |
return $sth; |
142 |
} |
} |
155 |
my $self = shift; |
my $self = shift; |
156 |
my @nodes; |
my @nodes; |
157 |
$logger->debug( __PACKAGE__ . "->getChildNodes()" ); |
$logger->debug( __PACKAGE__ . "->getChildNodes()" ); |
158 |
|
my $locator = $self->{locator}; |
159 |
|
#print Dumper($locator); exit; |
160 |
if (my $result = $self->sendCommand( 'SHOW TABLES;' ) ) { |
if (my $result = $self->sendCommand( 'SHOW TABLES;' ) ) { |
161 |
my $dbname = getDbNameByDsn($self->{locator}->{dbi}->{dsn}); |
my $dbname = getDbNameByDsn($self->{locator}->{dbi}->{dsn}); |
162 |
my $key = "Tables_in_$dbname"; |
my $key = "Tables_in_$dbname"; |
250 |
|
|
251 |
} |
} |
252 |
|
|
253 |
|
sub getCOREHANDLE2 { |
254 |
|
my $self = shift; |
255 |
|
return $self->{_COREHANDLE}; |
256 |
|
} |
257 |
|
|
258 |
1; |
1; |