feat(db): prepared add and remove function

This commit is contained in:
2026-07-08 20:20:42 +02:00
parent 3d2c0487b7
commit c929fdfda6
+25 -1
View File
@@ -25,11 +25,35 @@ class ContributionStore {
$this->pdo->exec(' $this->pdo->exec('
CREATE TABLE IF NOT EXISTS contributions ( CREATE TABLE IF NOT EXISTS contributions (
provider TEXT NOT NULL, provider TEXT NOT NULL,
date TEXT NOT NULL, date INTEGER NOT NULL,
count INTEGER NOT NULL CHECK (count >= 0), count INTEGER NOT NULL CHECK (count >= 0),
PRIMARY KEY (provider, date) PRIMARY KEY (provider, date)
) WITHOUT ROWID, STRICT ) 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{
}
} }