--- trunk/index_DBI_tag.pm 2005/01/23 02:02:10 641 +++ trunk/index_DBI_filter.pm 2005/01/23 14:31:02 642 @@ -68,7 +68,9 @@ my $sql_delete = "delete from $index"; my $sth = $self->{dbh}->prepare($sql_delete) || confess "can't prepare: $sql_delete"; - unless ($sth->execute()) { + if ($sth->execute()) { + print STDERR "## deleted rows from table $index\n" if ($debug); + } else { # can't delete from table, assume it doesn't exists! $self->{dbh}->rollback; $self->{dbh}->do($sql) || confess "SQL: $sql ".$self->{dbh}->errstr(); @@ -83,7 +85,7 @@ my $field = shift; my $index_data = shift || print STDERR "\$index->insert($field,NULL,...)"; my $display = shift || $index_data; - my $tag = shift; + my $filter = shift; if (! $index_data) { print STDERR "\$index->insert() -- no value to insert\n"; @@ -106,7 +108,7 @@ } $self->{c}->{$uc}->{$field}->{count}++; - $self->{c}->{$uc}->{$field}->{tag}->{$tag}++ if ($tag); + $self->{c}->{$uc}->{$field}->{filter}->{$filter}++ if ($filter); } sub count { @@ -207,12 +209,12 @@ ); }); - $self->delete_and_create('tags', qq{ - create table tags ( - tag varchar(255), + $self->delete_and_create('filters', qq{ + create table filters ( + filter varchar(255), ord int, count int, - primary key (tag,ord) + primary key (filter,ord) ); }); @@ -224,8 +226,8 @@ my $sql = "insert into index (name,ord,item,display,count) values (?,?,?,?,?)"; my $sth_index = $self->{dbh}->prepare($sql) || confess "$sql: ".$self->{dbh}->errstr(); - $sql = "insert into tags (tag, ord, count) values (?,?,?)"; - my $sth_tag = $self->{dbh}->prepare($sql) || confess "$sql: ".$self->{dbh}->errstr(); + $sql = "insert into filters (filter, ord, count) values (?,?,?)"; + my $sth_filter = $self->{dbh}->prepare($sql) || confess "$sql: ".$self->{dbh}->errstr(); my $ord = 0; foreach my $key (@items) { @@ -240,11 +242,11 @@ $self->{c}->{$key}->{$field}->{count}, ); - # store tags - next unless ($self->{c}->{$key}->{$field}->{tag}); + # store filters + next unless ($self->{c}->{$key}->{$field}->{filter}); - foreach my $tag (keys %{$self->{c}->{$key}->{$field}->{tag}}) { - $sth_tag->execute( $tag, $ord, $self->{c}->{$key}->{$field}->{tag}->{$tag} ); + foreach my $filter (keys %{$self->{c}->{$key}->{$field}->{filter}}) { + $sth_filter->execute( $filter, $ord, $self->{c}->{$key}->{$field}->{filter}->{$filter} ); } }