diff --git a/src/WriteDB.php b/src/WriteDB.php index ef4f0ef..75f86e2 100644 --- a/src/WriteDB.php +++ b/src/WriteDB.php @@ -42,8 +42,9 @@ public function __construct($configData = array()) { public function write() { $pdo = new PDO($this->dsn, $this->userName, $this->password); + $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - $stat = $pdo->prepare("INSERT INTO ".$this->tableName." SET ".$this->timeFieldName."=:d"); + $stat = $pdo->prepare("INSERT INTO ".$this->tableName." (".$this->timeFieldName.") VALUES (:d)"); foreach($this->dataManager->getData() as $item) { $stat->bindValue('d', $item->getDateTimeAs('Y-m-d H:i:s'), PDO::PARAM_STR);