Save to database #13
@@ -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{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user