Game.sql.php 808 Bytes
Newer Older
Zohten's avatar
Zohten committed
1 2 3 4 5 6 7
<?php

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

Zohten's avatar
Zohten committed
8 9
Game::addSqlQuery(
    'GAME_LIST_PUBLIC',
Zohten's avatar
Zohten committed
10
    'SELECT ID_GAME, NB_PLAYER, u.LOGIN
Zohten's avatar
Zohten committed
11
    FROM(
Zohten's avatar
Zohten committed
12
    SELECT g.ID_GAME, count(p.ID_USER) as NB_PLAYER, count(r.ID_ROUND) as NB_ROUND_PLAYED, p.ID_USER
Zohten's avatar
Zohten committed
13
    FROM MJ_GAME as g
Zohten's avatar
Zohten committed
14 15
    JOIN MJ_ROUND as r on g.ID_GAME = r.ID_GAME
    JOIN MJ_PLAY as p on r.ID_ROUND = p.ID_ROUND
Zohten's avatar
Zohten committed
16
    WHERE g.PRIVATE=0 AND p.HOST=1
Zohten's avatar
Zohten committed
17 18
    GROUP BY g.ID_GAME, p.ID_USER
    ) as r
Zohten's avatar
Zohten committed
19
    JOIN MJ_USER as u on r.ID_USER=u.ID_USER
Zohten's avatar
Zohten committed
20
    WHERE r.NB_PLAYER <=3 AND r.NB_ROUND_PLAYED=1'
Zohten's avatar
Zohten committed
21 22
);

Zohten's avatar
Zohten committed
23 24 25
Game::addSqlQuery(
    'GAME_GET_WITH_ID',
    'SELECT * FROM MJ_GAME WHERE ID_GAME=:id'
Zohten's avatar
Zohten committed
26 27 28 29 30 31
);

Game::addSqlQuery(
    'GAME_CREATE',
    'INSERT INTO MJ_GAME (ID_GAME, PRIVATE, CREATION_TIME)
    VALUES (NULL, :is_private, :creation_time)'
Zohten's avatar
Zohten committed
32
);