From: Banana Date: Tue, 5 Jul 2011 06:47:58 +0000 (+0200) Subject: variable scope X-Git-Tag: 2.1-alpha-2019-0-29~109 X-Git-Url: http://91.132.146.200/gitweb/?a=commitdiff_plain;h=467b55f308e2d10133c711d50d283f975d70dcef;p=insipid.git variable scope --- diff --git a/lib/Insipid/Tags.pm b/lib/Insipid/Tags.pm index 0a5148d..ad98d8f 100755 --- a/lib/Insipid/Tags.pm +++ b/lib/Insipid/Tags.pm @@ -48,6 +48,8 @@ sub tag_operations { check_access(); + my ($sql,$sth,$sql1, $sth1, $sql2,$sth2); + if(param('save') && param('newName')) { print '

Reanming...

'; @@ -59,34 +61,34 @@ sub tag_operations { # if check then check is the new tagId my $check = get_tag_id_by_name($newTag); if($check && ($check != $oldTagId)) { - my $sql = "SELECT bookmark_id, tag_id + $sql = "SELECT bookmark_id, tag_id FROM `$tbl_bookmark_tags` WHERE tag_id = ?"; - my $sth = $dbh->prepare($sql); + $sth = $dbh->prepare($sql); $sth->execute($oldTagId); while(my ($bid, $tid) = $sth->fetchrow_array) { - my $sql1 = "DELETE FROM `$tbl_bookmark_tags` + $sql1 = "DELETE FROM `$tbl_bookmark_tags` WHERE bookmark_id = ? AND tag_id = ?"; - my $sth1 = $dbh->prepare($sql1); + $sth1 = $dbh->prepare($sql1); $sth1->execute($bid,$tid); - my $sql2 = "INSERT IGNORE INTO `$tbl_bookmark_tags` + $sql2 = "INSERT IGNORE INTO `$tbl_bookmark_tags` SET bookmark_id = ?, tag_id = ?"; - my $sth2 = $dbh->prepare($sql2); + $sth2 = $dbh->prepare($sql2); $sth2->execute($bid,$check); } # remove the old one - my $sql = "DELETE FROM `$tbl_tags` WHERE id = ?"; - my $sth = $dbh->prepare($sql); + $sql = "DELETE FROM `$tbl_tags` WHERE id = ?"; + $sth = $dbh->prepare($sql); $sth->execute($oldTagId); } else { # just rename the tag - my $sql = "UPDATE $tbl_tags SET name = ? WHERE id = ?"; - my $sth = $dbh->prepare($sql); + $sql = "UPDATE $tbl_tags SET name = ? WHERE id = ?"; + $sth = $dbh->prepare($sql); $sth->execute($newTag,$oldTagId); } @@ -105,10 +107,10 @@ sub tag_operations { my $oldTagId = get_tag_id_by_name($delTagName); my $moveToTagId = get_tag_id_by_name($moveToTagName); if($oldTagId && $moveToTagId) { - my $sql = "UPDATE IGNORE `$tbl_bookmark_tags` + $sql = "UPDATE IGNORE `$tbl_bookmark_tags` SET `tag_id` = ? WHERE `tag_id` = ?"; - my $sth = $dbh->prepare($sql); + $sth = $dbh->prepare($sql); $sth->execute($moveToTagId,$oldTagId); } }