Skip to content

Commit

Permalink
Upgrade DB for tests if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
leftouterjoins committed Nov 12, 2023
1 parent 1c0e293 commit 7389c33
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Brickner/Podsumer/State.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ function __construct(Main $main)
$this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$this->checkDBInstall();

if (false === $this->main->getTestMode()) {
$this->checkDBVersion();
}
$this->checkDBVersion();
}

protected function installTables()
Expand Down Expand Up @@ -73,6 +70,12 @@ protected function query(string $sql, array $params = []): array|bool

} catch (Exception $e) {
$this->main->log($e->getMessage());

if ($this->main->getTestMode()) {
echo $e->getMessage();
}


return false;
}
}
Expand All @@ -97,6 +100,7 @@ public function addFeed(Feed $feed)
$sql = 'INSERT INTO feeds (url_hash, name, last_update, url, description, image, image_url) VALUES (:url_hash, :name, :last_update, :url, :description, :image, :image_url) ON CONFLICT(url_hash) DO UPDATE SET name=:name, last_update=:last_update, description=:description, image=:image, image_url=:image_url';
$this->query($sql, $feed_rec);
$feed_id = $this->pdo->lastInsertId();

if ('0' !== $feed_id) {
$feed->setFeedId(intval($feed_id));
}
Expand Down

0 comments on commit 7389c33

Please sign in to comment.