mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +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 ----------
|
# ---------- decide target ----------
|
||||||
|
|
||||||
if ($ua =~ m/FHEM/) {
|
if ($ua =~ m/FHEM/) {
|
||||||
insertDB();
|
my $result = insertDB();
|
||||||
print header("application/x-www-form-urlencoded");
|
print header("application/x-www-form-urlencoded");
|
||||||
print "==> ok";
|
if $result {
|
||||||
|
print "==> ok"
|
||||||
|
} else {
|
||||||
|
print "==> error"
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
viewStatistics();
|
viewStatistics();
|
||||||
}
|
}
|
||||||
@ -80,9 +84,10 @@ sub insertDB() {
|
|||||||
$dbh = DBI->connect($dsn,"","", { RaiseError => 1, ShowErrorStatement => 1 }) ||
|
$dbh = DBI->connect($dsn,"","", { RaiseError => 1, ShowErrorStatement => 1 }) ||
|
||||||
die "Cannot connect: $DBI::errstr";
|
die "Cannot connect: $DBI::errstr";
|
||||||
$sth = $dbh->prepare(q{INSERT OR REPLACE INTO jsonNodes(uniqueID,geo,json) VALUES(?,?,?)});
|
$sth = $dbh->prepare(q{INSERT OR REPLACE INTO jsonNodes(uniqueID,geo,json) VALUES(?,?,?)});
|
||||||
$sth->execute($uniqueID,$geo,$json);
|
my $result = $sth->execute($uniqueID,$geo,$json);
|
||||||
add2total();
|
add2total() if $result;
|
||||||
$dbh->disconnect();
|
$dbh->disconnect();
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub getLocation() {
|
sub getLocation() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user