'SET NAMES \'UTF8\'')); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); if ($pdo->beginTransaction()) { try { $statement = $pdo->prepare("SELECT * FROM `data` ORDER BY `ERSTER` DESC LIMIT 1;"); if ($statement->execute()) { $nbrofrows = $statement->rowCount(); if (1==$nbrofrows) { $row = $statement->fetch(); $lasttime = (int)($row["LETZTER"]); $firsttime = (int)($row["ERSTER"]); } else { echo $nbrofrows; echo ' rows***'; while ($nbrofrows > 0) { $nbrofrows = $nbrofrows - 1; $statement->fetch(); } $lasttime = (int)-99999; } if (($datum - $lasttime) > maxpause) { $befehl="INSERT INTO `data` (`ERSTER`, `LETZTER`, `ANZAHL`) VALUES (?, ?, 1);"; $arguments = array($datum, $datum); } else { $befehl="UPDATE `data` SET `ANZAHL` = `ANZAHL` + 1, `LETZTER` = ? WHERE `data`.`ERSTER` = ?;"; $arguments = array($datum, $firsttime); } $statement = $pdo->prepare($befehl); if ($statement->execute($arguments)) { $nbrofrows = $statement->rowCount(); while ($nbrofrows > 0) { $nbrofrows = $nbrofrows - 1; $statement->fetch(); } } else { echo 'Database Error 2***'; } } else { echo 'Database Error 1***'; } if (!$dbh->commit()) { echo 'Database Error 3***'; } } catch (Exception $e) { echo 'Exception ', $e->getMessage(), "\r\n"; } } else { echo 'Database Error 0***'; } } catch (Exception $e) { echo 'Exception ', $e->getMessage(), "\r\n"; } $statement=null; $pdo=null; ?>X