예제 #1
0
 public function __construct()
 {
     $className = Query::stripNamespaceFromClassName($this);
     $this->className = "Models\\Tables\\" . substr($className, 0, strlen($className) - 3);
     $this->tableName = strtolower(substr($className, 0, strlen($className) - 3));
     $this->dbManager = DBManager::getInstance();
 }
예제 #2
0
 public function incrementLevel()
 {
     $levelActuel = Ajax::get('levelActuel');
     $nbInstruction = Ajax::get('tokensLength');
     $nbInstructionExecuted = Ajax::get('nbInstructions');
     $scoreValue = Ajax::get('score');
     $idJoueur = Session::get('id');
     $lvlJoueur = Session::get('level');
     echo "Nous sommes au level " . $levelActuel . " le joueur est au level " . $lvlJoueur;
     if ($levelActuel - 1 == $lvlJoueur) {
         $sql = "insert into score values (" . Session::get('id') . "," . $levelActuel . "," . $nbInstructionExecuted . "," . $nbInstruction . "," . $scoreValue . ");";
         $sql2 = "update personne set currentLvl = " . $levelActuel . " where id= " . $idJoueur . ";";
         echo $sql;
         echo $sql2;
         $instanceofdb = $this->entityManager = DBManager::getInstance();
         $instanceofdb->prepare($sql);
         $instanceofdb->execute();
         $instanceofdb->prepare($sql2);
         $instanceofdb->execute();
         //currentLvl ++
         Session::set('level', $levelActuel);
     } else {
         //si le niveau du jeu est inférieur à celui du joueur, on update son score s'il est meilleur
         $user = $this->userSQL->findById(Session::get('id'));
         if ($user->score < $scoreValue) {
             $sql = "update score set score = " . $scoreValue . ", nbInstructions= " . $nbInstructionExecuted . ", nbLignes= " . $nbInstruction . " where idPlayer= " . $idJoueur . ";";
             $instanceofdb = $this->entityManager = DBManager::getInstance();
             $instanceofdb->prepare($sql);
             $instanceofdb->execute();
         }
     }
 }
예제 #3
0
 public function lier($idAlbum, $idPhoto)
 {
     $sql = new AlbumSQL();
     $a = $sql->findById($idAlbum);
     if ($a->utilisateur_id == Session::get('id')) {
         $pdo = DBManager::getInstance()->getPDO();
         $q = $pdo->prepare("DELETE FROM contient WHERE photo_id=?");
         $q->execute(array($idPhoto));
         $c = new Contient($idAlbum, $idPhoto);
         EntityManager::getInstance()->save($c);
     }
     // Url::previous();
 }