From a41917b9d4a1e7215b785599b38236844b9a4f78 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 14 Apr 2011 23:46:45 +0100 Subject: [PATCH] Don't hide errors. And different SQL format works in MySQL and Postgresql. --- src/WriteDB.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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);