diff --git a/PlayBot/commands/get.pm b/PlayBot/commands/get.pm index 1cf57020cad0eed99034132652f3786b16c9c7f8..cbd9e0052c9831b3cb6a65515b1af8ca2c84d460 100644 --- a/PlayBot/commands/get.pm +++ b/PlayBot/commands/get.pm @@ -75,7 +75,7 @@ sub exec { from playbot_tags where id = ? "); - $sth->execute($content->[0]); + $sth->execute($content->{id}); my @tags; while (my $data = $sth->fetch) { @@ -84,17 +84,9 @@ sub exec { push @tags, $tag; } - my %content_h; - $content_h{'id'} = $content->[0]; - $content_h{'author'} = $content->[1]; - $content_h{'title'} = $content->[2]; - $content_h{'url'} = $content->[3]; - $content_h{'duration'} = $content->[4]; - $content_h{'external_id'} = $content->[5]; - $content_h{'site'} = $content->[6]; - $content_h{'tags'} = \@tags; + $content->{'tags'} = \@tags; - my $irc_msg = PlayBot::utils::print::print(\%content_h); + my $irc_msg = PlayBot::utils::print::print($content); # if in query if ($chan !~ /^#/) { @@ -114,12 +106,12 @@ sub exec { VALUES (?,?,?)'); $log->error("Couldn't prepare querie; aborting") unless (defined $sth); - $sth->execute($content->[0], $chan, "PlayBot") + $sth->execute($content->{id}, $chan, "PlayBot") or $log->error("Couldn't finish transaction: " . $dbh->errstr); $dbh->commit(); - return $content->[0]; + return $content->{id}; } diff --git a/PlayBot/utils/db/get.pm b/PlayBot/utils/db/get.pm index 305135a7c1a1c401522e2e2c3c6c2b52a9514732..7f91f6c367ade2aa18a20b6274128fb491e38cf0 100644 --- a/PlayBot/utils/db/get.pm +++ b/PlayBot/utils/db/get.pm @@ -54,7 +54,17 @@ sub get { # if id was precised, we (and so the user) know there is no more results $self->_clean($chan) if ($query->id >= 0); - return $result; + return undef unless $result; + + my %content; + $content{'id'} = $result->[0]; + $content{'author'} = $result->[1]; + $content{'title'} = $result->[2]; + $content{'url'} = $result->[3]; + $content{'duration'} = $result->[4]; + $content{'external_id'} = $result->[5]; + $content{'site'} = $result->[6]; + return \%content; } sub get_rows {