/[cvs]/nfo/perl/libs/Data/Storage/Handler/DBI.pm
ViewVC logotype

Diff of /nfo/perl/libs/Data/Storage/Handler/DBI.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8 by joko, Sun Dec 1 22:20:43 2002 UTC revision 1.10 by joko, Sun Dec 15 02:02:22 2002 UTC
# Line 3  Line 3 
3  #  $Id$  #  $Id$
4  #  #
5  #  $Log$  #  $Log$
6    #  Revision 1.10  2002/12/15 02:02:22  joko
7    #  + fixed logging-message
8    #
9    #  Revision 1.9  2002/12/05 07:58:20  joko
10    #  + now using Tie::SecureHash as a base for the COREHANDLE
11    #  + former public COREHANDLE becomes private _COREHANDLE now
12    #
13  #  Revision 1.8  2002/12/01 22:20:43  joko  #  Revision 1.8  2002/12/01 22:20:43  joko
14  #  + sub createDb (from Storage.pm)  #  + sub createDb (from Storage.pm)
15  #  #
# Line 74  sub connect { Line 81  sub connect {
81          #use Data::Dumper; print Dumper($self->{dbi});          #use Data::Dumper; print Dumper($self->{dbi});
82                    
83          eval {          eval {
84            $self->{COREHANDLE} = DBI->connect( $dsn, '', '', $self->{locator}->{dbi} );            $self->{_COREHANDLE} = DBI->connect( $dsn, '', '', $self->{locator}->{dbi} );
85            if (!$self->{COREHANDLE}) {            if (!$self->{_COREHANDLE}) {
86              $logger->warning( __PACKAGE__ . "->connect failed: " . DBI::errstr );              $logger->warning( __PACKAGE__ . "->connect failed: " . DBI::errstr );
87              return;              return;
88            }            }
# Line 97  sub configureCOREHANDLE { Line 104  sub configureCOREHANDLE {
104    
105    $logger->debug( __PACKAGE__ . "->configureCOREHANDLE" );    $logger->debug( __PACKAGE__ . "->configureCOREHANDLE" );
106    
107    return if !$self->{COREHANDLE};    return if !$self->{_COREHANDLE};
108    
109    # apply configured modifications to DBI-handle    # apply configured modifications to DBI-handle
110      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}) {
111        $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});
112      }      }
113      if (exists $self->{locator}->{dbi}->{RaiseError}) {      if (exists $self->{locator}->{dbi}->{RaiseError}) {
114        $self->{COREHANDLE}->{RaiseError} = $self->{locator}->{dbi}->{RaiseError};        $self->{_COREHANDLE}->{RaiseError} = $self->{locator}->{dbi}->{RaiseError};
115      }      }
116      if (exists $self->{locator}->{dbi}->{PrintError}) {      if (exists $self->{locator}->{dbi}->{PrintError}) {
117        $self->{COREHANDLE}->{PrintError} = $self->{locator}->{dbi}->{PrintError};        $self->{_COREHANDLE}->{PrintError} = $self->{locator}->{dbi}->{PrintError};
118      }      }
119      if (exists $self->{locator}->{dbi}->{HandleError}) {      if (exists $self->{locator}->{dbi}->{HandleError}) {
120        $self->{COREHANDLE}->{HandleError} = $self->{locator}->{dbi}->{HandleError};        $self->{_COREHANDLE}->{HandleError} = $self->{locator}->{dbi}->{HandleError};
121      }      }
122    
123  }  }
# Line 121  sub _sendSql { Line 128  sub _sendSql {
128        
129    # two-level handling for implicit connect:    # two-level handling for implicit connect:
130    # if there's no corehandle ...    # if there's no corehandle ...
131    if (!$self->{COREHANDLE}) {    if (!$self->{_COREHANDLE}) {
132      # ... try to connect, but ...      # ... try to connect, but ...
133      $self->connect();      $self->connect();
134      # ... 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
135      if (!$self->{COREHANDLE}) {      if (!$self->{_COREHANDLE}) {
136        return;        return;
137      }      }
138    }    }
139        
140    #print "prepare sql: $sql\n";    #print "prepare sql: $sql\n";
141        
142    my $sth = $self->{COREHANDLE}->prepare($sql);    my $sth = $self->{_COREHANDLE}->prepare($sql);
143    $sth->execute();    $sth->execute();
144    return $sth;    return $sth;
145  }  }
# Line 151  sub getChildNodes { Line 158  sub getChildNodes {
158    my $self = shift;    my $self = shift;
159    my @nodes;    my @nodes;
160    $logger->debug( __PACKAGE__ . "->getChildNodes()" );    $logger->debug( __PACKAGE__ . "->getChildNodes()" );
161      my $locator = $self->{locator};
162      #print Dumper($locator); exit;
163    if (my $result = $self->sendCommand( 'SHOW TABLES;' ) ) {    if (my $result = $self->sendCommand( 'SHOW TABLES;' ) ) {
164      my $dbname = getDbNameByDsn($self->{locator}->{dbi}->{dsn});      my $dbname = getDbNameByDsn($self->{locator}->{dbi}->{dsn});
165      my $key = "Tables_in_$dbname";      my $key = "Tables_in_$dbname";
# Line 177  sub getListUnfiltered { Line 186  sub getListUnfiltered {
186  sub sendQuery {  sub sendQuery {
187    my $self = shift;    my $self = shift;
188    my $query = shift;    my $query = shift;
189    
190      $logger->debug( __PACKAGE__ . "->sendQuery" );
191    
192    #my $sql = "SELECT cs FROM $self->{metainfo}->{$descent}->{node} WHERE $self->{metainfo}->{$descent}->{IdentProvider}->{arg}='$self->{entry}->{source}->{ident}';";    #my $sql = "SELECT cs FROM $self->{metainfo}->{$descent}->{node} WHERE $self->{metainfo}->{$descent}->{IdentProvider}->{arg}='$self->{entry}->{source}->{ident}';";
193    #my $result = $self->{metainfo}->{$descent}->{storage}->sendCommand($sql);    #my $result = $self->{metainfo}->{$descent}->{storage}->sendCommand($sql);
194    my @crits;    my @crits;
# Line 196  sub sendQuery { Line 208  sub sendQuery {
208  sub eraseAll {  sub eraseAll {
209    my $self = shift;    my $self = shift;
210    my $classname = shift;    my $classname = shift;
211      $logger->debug( __PACKAGE__ . "->eraseAll" );
212    my $sql = "DELETE FROM $classname";    my $sql = "DELETE FROM $classname";
213    $self->sendCommand($sql);    $self->sendCommand($sql);
214  }  }
# Line 244  sub createDb { Line 257  sub createDb {
257        
258  }  }
259    
260    sub getCOREHANDLE2 {
261      my $self = shift;
262      return $self->{_COREHANDLE};
263    }
264    
265  1;  1;

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.10

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed