From a3a0cd84b74f9afa45e536f0d275c41d40828dcf Mon Sep 17 00:00:00 2001 From: Alexandre Morignot <erdnaxeli@cervoi.se> Date: Sun, 10 May 2015 13:47:56 +0200 Subject: [PATCH] [sites/parser] mysql_insert_id was not working --- lib/sites/parser.pm | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/lib/sites/parser.pm b/lib/sites/parser.pm index 12d744f..8e72e44 100644 --- a/lib/sites/parser.pm +++ b/lib/sites/parser.pm @@ -73,8 +73,6 @@ sub parse { $sth->execute($content{'site'}, $content{'url'}, $content{'author'}, $content{'title'}, $content{'duration'}); - - $dbh->commit; }; if ($@) { $log->error("Couldn't finish transaction: " . $@); @@ -82,21 +80,13 @@ sub parse { } # sélection de l'id de la vidéo insérée - $id = $sth->{mysql_insertid}; - if (!$id) { - # la vido avait déjà été insérée - # L'état de la bdd est stable (puisqu'on a en fait rien fait), - # on peut commiter. - $dbh->commit; - - my $sth = $dbh->prepare('SELECT id FROM playbot WHERE url = ?'); - $log->error("Couldn't prepare querie; aborting") unless (defined $sth); + my $sth = $dbh->prepare('SELECT id FROM playbot WHERE url = ?'); + $log->error("Couldn't prepare querie; aborting") unless (defined $sth); - $sth->execute($content{'url'}) - or $log->error("Couldn't finish transaction: " . $dbh->errstr); + $sth->execute($content{'url'}) + or $log->error("Couldn't finish transaction: " . $dbh->errstr); - $id = $sth->fetch->[0]; - } + $id = $sth->fetch->[0]; # insertion du chan my $sth = $dbh->prepare(' @@ -107,7 +97,6 @@ sub parse { $sth->execute($id, $chan->[0], $nick) or $log->error("Couldn't finish transaction: " . $dbh->errstr); - # in all cases, we commit now $dbh->commit; commands::parser::tag($msg, $chan); -- GitLab