From c59e7316fbc790c44b16d18c4870da80c34fb223 Mon Sep 17 00:00:00 2001 From: Ian Beckwith Date: Sun, 17 Oct 2010 05:19:15 +0100 Subject: [PATCH] merge duplicate id lookup functions --- lib/ID3FS/DB.pm | 8 -------- lib/ID3FS/PathElement/Album.pm | 2 +- lib/ID3FS/PathElement/Artist.pm | 2 +- lib/ID3FS/PathElement/File.pm | 2 +- lib/ID3FS/PathElement/Tag.pm | 2 +- lib/ID3FS/PathElement/Tagval.pm | 2 +- 6 files changed, 5 insertions(+), 13 deletions(-) diff --git a/lib/ID3FS/DB.pm b/lib/ID3FS/DB.pm index 1638c54..29c50e3 100644 --- a/lib/ID3FS/DB.pm +++ b/lib/ID3FS/DB.pm @@ -169,14 +169,6 @@ sub last_update return $newval; } -sub id -{ - my($self, $type, $val)=@_; - my $sql="SELECT id FROM $type WHERE name=?"; - my ($id)=$self->cmd_onerow($sql, $val); - return($id); -} - sub tag_has_values { my($self, $id)=@_; diff --git a/lib/ID3FS/PathElement/Album.pm b/lib/ID3FS/PathElement/Album.pm index 46836aa..9826fd1 100644 --- a/lib/ID3FS/PathElement/Album.pm +++ b/lib/ID3FS/PathElement/Album.pm @@ -12,7 +12,7 @@ sub new $self->{db}=shift; $self->{name}=shift; - $self->{id}=($self->{db}->id("albums", $self->{name})); + $self->{id}=($self->{db}->lookup_id("albums", $self->{name})); return(undef) unless(defined($self->{id})); return $self; } diff --git a/lib/ID3FS/PathElement/Artist.pm b/lib/ID3FS/PathElement/Artist.pm index 9bcf4aa..a0bc50b 100644 --- a/lib/ID3FS/PathElement/Artist.pm +++ b/lib/ID3FS/PathElement/Artist.pm @@ -12,7 +12,7 @@ sub new $self->{db}=shift; $self->{name}=shift; - $self->{id}=($self->{db}->id("artists", $self->{name})); + $self->{id}=($self->{db}->lookup_id("artists", $self->{name})); return(undef) unless(defined($self->{id})); return $self; } diff --git a/lib/ID3FS/PathElement/File.pm b/lib/ID3FS/PathElement/File.pm index 6987440..7a5a1c7 100644 --- a/lib/ID3FS/PathElement/File.pm +++ b/lib/ID3FS/PathElement/File.pm @@ -12,7 +12,7 @@ sub new $self->{db}=shift; $self->{name}=shift; - $self->{id}=$self->{db}->id("files", $self->{name}); + $self->{id}=$self->{db}->lookup_id("files", $self->{name}); return(undef) unless(defined($self->{id})); return $self; } diff --git a/lib/ID3FS/PathElement/Tag.pm b/lib/ID3FS/PathElement/Tag.pm index 3185955..ad68f06 100644 --- a/lib/ID3FS/PathElement/Tag.pm +++ b/lib/ID3FS/PathElement/Tag.pm @@ -13,7 +13,7 @@ sub new $self->{db}=shift; $self->{name}=shift; $self->{parents_id}=shift; - $self->{id}=$self->{db}->id("tags", $self->{name}); + $self->{id}=$self->{db}->lookup_id("tags", $self->{name}); return(undef) unless(defined($self->{id})); return($self); } diff --git a/lib/ID3FS/PathElement/Tagval.pm b/lib/ID3FS/PathElement/Tagval.pm index 255e2a0..3b2a77b 100644 --- a/lib/ID3FS/PathElement/Tagval.pm +++ b/lib/ID3FS/PathElement/Tagval.pm @@ -12,7 +12,7 @@ sub new $self->{db}=shift; $self->{name}=shift; - $self->{id}=$self->{db}->id("tagvals", $self->{name}); + $self->{id}=$self->{db}->lookup_id("tagvals", $self->{name}); return(undef) unless(defined($self->{id})); return $self; } -- 2.11.0