Vues affichages des listes par categorie/genre et fiche detaillee des jeux et creation de la page detail du jeu avec jointures gauches pour le developpeur et le poster
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Game_model extends CI_Model {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->load->database();
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère les jeux appartenant à une catégorie spécifique
|
||||
*/
|
||||
public function get_by_category($category_id) {
|
||||
$this->db->select('game.*');
|
||||
$this->db->from('game');
|
||||
|
||||
$this->db->join('game_category', 'game_category.gameId = game.gameId');
|
||||
|
||||
$this->db->where('game_category.categoryId', $category_id);
|
||||
|
||||
$query = $this->db->get();
|
||||
return $query->result_array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère les jeux appartenant à un genre spécifique
|
||||
*/
|
||||
public function get_by_genre($genre_id) {
|
||||
$this->db->select('game.*');
|
||||
$this->db->from('game');
|
||||
|
||||
$this->db->join('game_genre', 'game_genre.gameId = game.gameId');
|
||||
|
||||
$this->db->where('game_genre.genreId', $genre_id);
|
||||
|
||||
$query = $this->db->get();
|
||||
return $query->result_array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère les détails complets d'un jeu (avec développeur et poster)
|
||||
*/
|
||||
public function get_by_id($game_id) {
|
||||
|
||||
$this->db->select('game.*, developer.name as developer_name, poster.url as poster_url');
|
||||
$this->db->from('game');
|
||||
|
||||
$this->db->join('developer', 'developer.developerId = game.developerId', 'left');
|
||||
|
||||
$this->db->join('poster', 'poster.posterId = game.posterId', 'left');
|
||||
|
||||
$this->db->where('game.gameId', $game_id);
|
||||
|
||||
$query = $this->db->get();
|
||||
|
||||
return $query->row_array();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user