From c929fdfda61fd9413afb69179038e18b361d9ab0 Mon Sep 17 00:00:00 2001 From: Haylan Date: Wed, 8 Jul 2026 20:20:42 +0200 Subject: [PATCH] feat(db): prepared add and remove function --- src/Service/ContributionStore.php | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/Service/ContributionStore.php b/src/Service/ContributionStore.php index 7d61f90..2c9f1ed 100644 --- a/src/Service/ContributionStore.php +++ b/src/Service/ContributionStore.php @@ -25,11 +25,35 @@ class ContributionStore { $this->pdo->exec(' CREATE TABLE IF NOT EXISTS contributions ( provider TEXT NOT NULL, - date TEXT NOT NULL, + date INTEGER NOT NULL, count INTEGER NOT NULL CHECK (count >= 0), PRIMARY KEY (provider, date) ) WITHOUT ROWID, STRICT '); } + + public function add(string $provider, int $unixtime, int $count):void{ + $stmt = $this->pdo->prepare(' + INSERT INTO contributions ( + provider, date, count + ) + VALUES( + ?,?,? + ) + '); + $stmt->execute([$provider,$unixtime,$count]); + } + + public function remove(string $provider, int $unixtime):void{ + $stmt = $this->pdo->prepare(' + DELETE contributions + WHERE provider LIKE ? and date = ? + '); + $stmt->execute([$provider,$unixtime]); + } + + public function all():void{ + + } }