|
@@ -0,0 +1,50 @@
|
|
1
|
+<?php
|
|
2
|
+
|
|
3
|
+class Score {
|
|
4
|
+ private $login;
|
|
5
|
+ private $score;
|
|
6
|
+ private $bdd;
|
|
7
|
+
|
|
8
|
+ function __construct($login) {
|
|
9
|
+ $this->bdd = new Connector();
|
|
10
|
+
|
|
11
|
+ $options = array(
|
|
12
|
+ "where" => array(
|
|
13
|
+ array("login", "=", $login);
|
|
14
|
+ )
|
|
15
|
+ );
|
|
16
|
+
|
|
17
|
+ $data = $bdd->Select("*", "scores", $options);
|
|
18
|
+ $this->login = $data['login'];
|
|
19
|
+ $this->score = $data['score'];
|
|
20
|
+ }
|
|
21
|
+
|
|
22
|
+ function getLogin() {
|
|
23
|
+ return $this->login;
|
|
24
|
+ }
|
|
25
|
+
|
|
26
|
+ function getScore() {
|
|
27
|
+ return $this->score;
|
|
28
|
+ }
|
|
29
|
+
|
|
30
|
+ public static function getScores($nRows, $direction = "desc") {
|
|
31
|
+ $bdd = new Connector();
|
|
32
|
+
|
|
33
|
+ $options = array(
|
|
34
|
+ "order by" => array("score", $direction),
|
|
35
|
+ "limit" => array($nRows)
|
|
36
|
+ );
|
|
37
|
+
|
|
38
|
+ $array = $bdd->Select("*", "scores", $options);
|
|
39
|
+ $scores = array();
|
|
40
|
+ foreach($array as $score) {
|
|
41
|
+ array_push($scores, new Score($score['login']));
|
|
42
|
+ }
|
|
43
|
+
|
|
44
|
+ return $scores;
|
|
45
|
+ }
|
|
46
|
+
|
|
47
|
+ public static function add($login, $score) {
|
|
48
|
+
|
|
49
|
+ }
|
|
50
|
+}
|