Hallo,
mein Datenbank Script wird als fehlerhaft in IPS markiert wenn die Datenbank nicht erreichbar ist,
kann ich diesen Fehler irgend wie abfangen?
<?
$dbconn = pg_connect("host=192.168.0.106 port=5432 dbname=ipsgraphenlogging user=ips password=ips") or die ('Verbindungsaufbau fehlgeschlagen: ' . pg_last_error());
if($IPS_SENDER == "Variable")
{
$variablenName = IPS_GetObject($IPS_VARIABLE);
$variable = IPS_GetVariable($IPS_VARIABLE);
$varType = $variable['VariableValue']['ValueType'];
$profil = IPS_GetVariableProfile($variable['VariableCustomProfile']);
$suffix = $profil['Suffix'];
setDataSql($IPS_VARIABLE, utf8_encode($variablenName['ObjectName']), utf8_encode($suffix), $IPS_VALUE, $varType, date('Y-m-d H:i'));
$Updates = GetValue(28854 /*[Datenbank PostgreSQL\Postgresql on Pi\DB-Updates]*/ );
$Updates = $Updates + 1;
SetValue(28854 /*[Datenbank PostgreSQL\Postgresql on Pi\DB-Updates]*/,$Updates);
}
function setDataSql($varID, $varName, $suffix, $value, $typ, $time)
{
global $dbconn;
$setSQL = 'INSERT INTO Variablen(varid, varname, varsuffix, value, typ, updatezeit) VALUES ';
$setSQL .= "('".$varID."','".$varName."','".$suffix."','".$value."','".$typ."','".$time."');";
pg_query($dbconn, $setSQL);
}
// Verbindung schliessen
pg_close($dbconn);
?>
Schöne Grüße
Thomas