-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscore.php
More file actions
34 lines (24 loc) · 720 Bytes
/
score.php
File metadata and controls
34 lines (24 loc) · 720 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
class Score {
private $conn;
function __construct(){
$dsn = 'mysql:host=localhost;dbname=memory';
$user = 'root';
$pass = 'root';
$score = 72;
$this->conn = new \PDO($dsn, $user, $pass);
}
function save($score){
$sql = "insert into scoretable (temps) values (:score)";
$params = ['score' => $score];
$stmt = $this->conn->prepare($sql);
$stmt->execute($params);
}
function get($limit=5){
$sql = "SELECT temps FROM scoretable ORDER BY temps ASC";
$stmt = $this->conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_CLASS);
return $result;
}
}