mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-12 16:46:35 +00:00
statistics2.cgi: add error handling for inserDB()
git-svn-id: https://svn.fhem.de/fhem/trunk@14404 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
83f506802a
commit
cdecd93734
@ -62,9 +62,13 @@ my $css = "style.css";
|
||||
# ---------- decide target ----------
|
||||
|
||||
if ($ua =~ m/FHEM/) {
|
||||
insertDB();
|
||||
my $result = insertDB();
|
||||
print header("application/x-www-form-urlencoded");
|
||||
print "==> ok";
|
||||
if $result {
|
||||
print "==> ok"
|
||||
} else {
|
||||
print "==> error"
|
||||
}
|
||||
} else {
|
||||
viewStatistics();
|
||||
}
|
||||
@ -80,9 +84,10 @@ sub insertDB() {
|
||||
$dbh = DBI->connect($dsn,"","", { RaiseError => 1, ShowErrorStatement => 1 }) ||
|
||||
die "Cannot connect: $DBI::errstr";
|
||||
$sth = $dbh->prepare(q{INSERT OR REPLACE INTO jsonNodes(uniqueID,geo,json) VALUES(?,?,?)});
|
||||
$sth->execute($uniqueID,$geo,$json);
|
||||
add2total();
|
||||
my $result = $sth->execute($uniqueID,$geo,$json);
|
||||
add2total() if $result;
|
||||
$dbh->disconnect();
|
||||
return $result;
|
||||
}
|
||||
|
||||
sub getLocation() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user