From cb63c32296213cc54aff09871b197a961342bd88 Mon Sep 17 00:00:00 2001 From: vbochet <vbochet@gmail.com> Date: Fri, 6 May 2016 18:09:12 +0200 Subject: [PATCH] =?UTF-8?q?Modification=20du=20mod=C3=A8le=20de=20jeu=20po?= =?UTF-8?q?ur=20ajouter=20une=20m=C3=A9thode=20de=20r=C3=A9cup=C3=A9ration?= =?UTF-8?q?=20des=20trois=20jeux=20les=20plus=20jou=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/model/Jeu.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/model/Jeu.php b/app/model/Jeu.php index d16773f..1e8d998 100644 --- a/app/model/Jeu.php +++ b/app/model/Jeu.php @@ -21,6 +21,21 @@ class Jeu extends Model { } + public static function getMostPlayed() { + $db = Database::getInstance(); + $sql = 'SELECT nom, COUNT(*) as "parties" FROM R_partie JOIN R_jeu ON slug = jeu GROUP BY nom ORDER BY parties DESC'; + $stmt = $db->query($sql); + $ret = array(); + $k = 0; + while($k<3 && ($elt = $stmt->fetch())) { + echo $elt['nom'].'<br>'; + $k++; + array_push($ret, $elt); + } + return $ret; + + } + public static function getSlugList() { $db = Database::getInstance(); $sql = "SELECT slug FROM R_jeu"; -- GitLab