From 4f880c7c0607a428931caac219bd86b18759ac67 Mon Sep 17 00:00:00 2001 From: Markus Birth Date: Sat, 16 Dec 2017 14:17:18 +0100 Subject: [PATCH] Cleanup. --- lib/TclUpdates/GotuObject.php | 0 lib/TclUpdates/SQLiteWriter.php | 9 ++++----- parse_files.php | 11 +++++++++-- 3 files changed, 13 insertions(+), 7 deletions(-) mode change 100755 => 100644 lib/TclUpdates/GotuObject.php mode change 100755 => 100644 lib/TclUpdates/SQLiteWriter.php diff --git a/lib/TclUpdates/GotuObject.php b/lib/TclUpdates/GotuObject.php old mode 100755 new mode 100644 diff --git a/lib/TclUpdates/SQLiteWriter.php b/lib/TclUpdates/SQLiteWriter.php old mode 100755 new mode 100644 index aee1836..94f8179 --- a/lib/TclUpdates/SQLiteWriter.php +++ b/lib/TclUpdates/SQLiteWriter.php @@ -10,9 +10,9 @@ class SQLiteWriter public function __construct() { $this->dbFile = 'otadb.db3'; - $this->pdo = new \PDO('sqlite:' . $this->dbFile, 0666, $sqlerror); + $this->pdo = new \PDO('sqlite:' . $this->dbFile); if ($this->pdo === false) { - return $sqlerror; + return false; } $this->pdo->exec('PRAGMA foreign_keys=on;'); } @@ -119,9 +119,8 @@ class SQLiteWriter )); if ($ok) { $key = $this->pdo->lastInsertId(); - echo "Added entry " . $key . PHP_EOL; - } else { - echo "FAILED inserting." . PHP_EOL; + return $key; } + return false; } } diff --git a/parse_files.php b/parse_files.php index 19a14af..52a2270 100755 --- a/parse_files.php +++ b/parse_files.php @@ -27,10 +27,17 @@ foreach ($file_list as $file) { echo 'XML not valid in ' . $filename . '!' . PHP_EOL; continue; } - echo 'Processing ' . $filename . PHP_EOL; + echo 'Processing ' . $filename . ' ...'; $g = GotuObject::fromXmlParser($xp); //print_r($g); if ($g->tv) { - $sqlw->addGotu($g, $file_date); + $result = $sqlw->addGotu($g, $file_date); + if ($result !== false) { + echo ' added as #' . $result . PHP_EOL; + } else { + echo ' NOT ADDED.' . PHP_EOL; + } + } else { + echo ' not a check XML' . PHP_EOL; } }