<?php

Game::addSqlQuery(
    'GAME_LIST',
    'SELECT * FROM MJ_GAME'
);

Game::addSqlQuery(
    'GAME_LIST_PUBLIC',
    'SELECT ID_GAME, NB_PLAYER, u.LOGIN
    FROM(
    SELECT g.ID_GAME, count(p.ID_USER) as NB_PLAYER, count(r.ID_ROUND) as NB_ROUND_PLAYED, p.ID_USER
    FROM MJ_GAME as g
    JOIN MJ_ROUND as r on g.ID_GAME = r.ID_GAME
    JOIN MJ_PLAY as p on r.ID_ROUND = p.ID_ROUND
    WHERE g.PRIVATE=0 AND p.HOST=1
    GROUP BY g.ID_GAME, p.ID_USER
    ) as r
    JOIN MJ_USER as u on r.ID_USER=u.ID_USER
    WHERE r.NB_PLAYER <=3 AND r.NB_ROUND_PLAYED=1'
);

Game::addSqlQuery(
    'GAME_GET_WITH_ID',
    'SELECT * FROM MJ_GAME WHERE ID_GAME=:id'
);

Game::addSqlQuery(
    'GAME_CREATE',
    'INSERT INTO MJ_GAME (ID_GAME, PRIVATE, CREATION_TIME)
    VALUES (NULL, :is_private, :creation_time)'
);