/[webpac]/trunk/index_DBI.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/index_DBI.pm

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

revision 13 by dpavlin, Sun Feb 16 22:41:37 2003 UTC revision 18 by dpavlin, Sat Feb 22 21:37:25 2003 UTC
# Line 37  sub delete_and_create { Line 37  sub delete_and_create {
37          my $sql = "select count(*) from $field";          my $sql = "select count(*) from $field";
38          my $sth = $self->{dbh}->prepare($sql) || die $self->{dbh}->errstr();          my $sth = $self->{dbh}->prepare($sql) || die $self->{dbh}->errstr();
39  # FIX: this is not a good way to check if table exists!  # FIX: this is not a good way to check if table exists!
40          if (1 || $sth->execute() && $sth->fetchrow_hashref) {          if ($sth->execute() && $sth->fetchrow_hashref) {
41                  my $sql = "drop table $field";                  my $sql = "drop table $field";
42  #               my $sth = $self->{dbh}->do($sql) || die "SQL: $sql ".$self->{dbh}->errstr();                  my $sth = $self->{dbh}->do($sql) || die "SQL: $sql ".$self->{dbh}->errstr();
43          }          }
44          $sql = "create table $field (          $sql = "create table $field (
45                          item varchar(255),                          item varchar(255),
# Line 48  sub delete_and_create { Line 48  sub delete_and_create {
48                          ord int,                          ord int,
49                          primary key (item,ident)                          primary key (item,ident)
50                  )";                  )";
51  #       $sth = $self->{dbh}->do($sql) || die "SQL: $sql ".$self->{dbh}->errstr();          $sth = $self->{dbh}->do($sql); # || warn "SQL: $sql ".$self->{dbh}->errstr();
         $sth = $self->{dbh}->do($sql) || warn "SQL: $sql ".$self->{dbh}->errstr();  
52    
53          $self->{dbh}->commit;          $self->{dbh}->commit;
54          $self->{dbh}->begin_work;          $self->{dbh}->begin_work;
# Line 59  sub insert { Line 58  sub insert {
58          my $self = shift;          my $self = shift;
59    
60          my $field = shift;          my $field = shift;
61          my $index_data = shift || return;          my $index_data = shift || print STDERR "\$index->insert($field,NULL,...)";
62          my $ident = shift || return;    # e.g. library id          my $ident = shift || '';        # e.g. library id
63    
64          if (! $index_data) {          if (! $index_data) {
65                  print STDERR "\$index->insert() -- no value to insert\n";                  print STDERR "\$index->insert() -- no value to insert\n";

Legend:
Removed from v.13  
changed lines
  Added in v.18

  ViewVC Help
Powered by ViewVC 1.1.26