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{ + + } }