diff --git a/JOURNAL.md b/JOURNAL.md
index 6f61072..5e3a1fb 100644
--- a/JOURNAL.md
+++ b/JOURNAL.md
@@ -82,4 +82,33 @@ Comment vas-tu écrire cette fonction public function ajouter() avec ces deux li
Dans notre fonction ajouter(), nous avons besoin de faire deux actions :
Charger un outil (helper) pour gérer les liens web. L'outil s'appelle 'url' et la commande à utiliser est helper().
Charger l'interface visuelle (vue) qui contiendra le formulaire. Nous allons l'appeler 'formulaire_ajout_vue' et la commande est view().
-En utilisant la syntaxe $this->load->..., comment écrirais-tu ces deux lignes complètes à l'intérieur de ta fonction ajouter() ?
\ No newline at end of file
+En utilisant la syntaxe $this->load->..., comment écrirais-tu ces deux lignes complètes à l'intérieur de ta fonction ajouter() ?
+
+
+## Séance 4 - Finalisation et Intégration du Projet (Front & Back)
+
+**Objectif de la séance :** Terminer l'architecture MVC, finaliser les filtres de tri (, lier le travail de nous deux et corriger les bugs de fusion (merge) pour rendre le site 100 % fonctionnel.
+
+**Travail de Tajeddine :**
+* Création des vues publiques de l'application : Accueil, listes de jeux filtrées, résultats de recherche et fiche détaillée.
+* Création des contrôleurs associés (`Home`, `Category`, `Genre`, `Game`).
+* Implémentation du moteur de recherche par mots-clés.
+* Mise en place des modèles de base pour les catégories et les genres.
+
+**Travail d'Ibrahim (:**
+* suppression de tout le HTML dans les contrôleurs
+* Tri (par Titre et Année) et création de la vue d'administration (`liste_jeux_vue.php`) incluant les boutons d'ajout, de modification et de suppression.
+* **Débogage global du projet suite à la fusion :**
+ * Activation de la base de données dans `$autoload['libraries']` pour éviter les plantages sur les pages publiques.
+ * Alignement des modèles (`Game_model`, `Category_model`, `Genre_model`) et des vues avec la réalité de la base de données MariaDB (correction des clés primaires `gameId` en `id`, et des colonnes `title` en `name`, `year` en `releaseYear`).
+ * Résolution du problème d'affichage des images stockées au format `mediumblob` en utilisant un encodage natif PHP (`base64_encode`).
+
+
+**Difficultés rencontrées :** * Énormément d'erreurs PHP ("Undefined array key") et SQL ("Erreur 1054 : Colonne inconnue") apparues après la fusion des codes, causées par des différences entre le nom des variables et le schéma réel de la base de données.
+* Difficulté à afficher l'image (Poster) du jeu
+
+
+**Usage de l'IA (Séance 4) :**
+* **Prompts utilisés :** Envoi des logs d'erreurs CodeIgniter (`Undefined array key`, `Call to undefined method`), requêtes SQL en erreur (Erreur 1054), et questions sur l'affichage d'une image BLOB en HTML.
+* **Extraits de réponse jugés utiles :** * L'IA m'a expliqué que la connexion à la BDD n'était pas persistante d'une page à l'autre sans l'Autoload.
+ * L'IA m'a fourni la syntaxe HTML/PHP exacte (``) pour afficher notre format d'image.
\ No newline at end of file
diff --git a/JOURNAL.md~ b/JOURNAL.md~
deleted file mode 100644
index e69de29..0000000
diff --git a/codeigniter-develop/application/config/autoload.php b/codeigniter-develop/application/config/autoload.php
index 6f31b14..052e9da 100644
--- a/codeigniter-develop/application/config/autoload.php
+++ b/codeigniter-develop/application/config/autoload.php
@@ -58,7 +58,7 @@ $autoload['packages'] = array();
|
| $autoload['libraries'] = array('user_agent' => 'ua');
*/
-$autoload['libraries'] = array();
+$autoload['libraries'] = array('database');
/*
| -------------------------------------------------------------------
diff --git a/codeigniter-develop/application/controllers/Category.php b/codeigniter-develop/application/controllers/Category.php
index 476d452..a56ac9b 100644
--- a/codeigniter-develop/application/controllers/Category.php
+++ b/codeigniter-develop/application/controllers/Category.php
@@ -8,22 +8,10 @@ class Category extends CI_Controller {
redirect('home');
}
- // 1. Charger les modèles nécessaires
$this->load->model('Game_model');
- $this->load->model('Category_model');
- // 2. Récupérer les infos de la catégorie pour afficher son nom
- $this->db->where('categoryId', $id);
- $data['category'] = $this->db->get('category')->row_array();
-
- if (empty($data['category'])) {
- show_404();
- }
-
- // 3. Récupérer tous les jeux de cette catégorie
$data['games'] = $this->Game_model->get_by_category($id);
- // 4. Envoyer le tout à une nouvelle vue
$this->load->view('games_list_view', $data);
}
}
\ No newline at end of file
diff --git a/codeigniter-develop/application/controllers/Genre.php b/codeigniter-develop/application/controllers/Genre.php
index fdf1703..bdd17e6 100644
--- a/codeigniter-develop/application/controllers/Genre.php
+++ b/codeigniter-develop/application/controllers/Genre.php
@@ -9,17 +9,9 @@ class Genre extends CI_Controller {
}
$this->load->model('Game_model');
- $this->load->model('Genre_model');
-
- $this->db->where('genreId', $id);
- $data['genre'] = $this->db->get('genre')->row_array();
-
- if (empty($data['genre'])) {
- show_404();
- }
$data['games'] = $this->Game_model->get_by_genre($id);
- $this->load->view('games_list_view', $data);
+ $this->load->view('genre_games_list_view', $data);
}
}
\ No newline at end of file
diff --git a/codeigniter-develop/application/models/Category_model.php b/codeigniter-develop/application/models/Category_model.php
index caaf08d..96cfc0d 100644
--- a/codeigniter-develop/application/models/Category_model.php
+++ b/codeigniter-develop/application/models/Category_model.php
@@ -8,27 +8,20 @@ class Category_model extends CI_Model {
$this->load->database();
}
- /**
- * Récupère toutes les catégories de la base de données
- */
public function get_all() {
$query = $this->db->get('category');
-
return $query->result_array();
}
-
- public function get_by_game($game_id) {
- $this->db->select('category.*');
- $this->db->from('category');
-
- $this->db->join('game_category', 'game_category.categoryId = category.categoryId');
-
- $this->db->where('game_category.gameId', $game_id);
-
- $query = $this->db->get();
-
- return $query->result_array();
- }
-
+ public function get_by_game($game_id) {
+ $this->db->select('category.*');
+ $this->db->from('category');
+
+ $this->db->join('game_category', 'game_category.categoryId = category.id');
+
+ $this->db->where('game_category.gameId', $game_id);
+
+ $query = $this->db->get();
+ return $query->result_array();
+ }
}
\ No newline at end of file
diff --git a/codeigniter-develop/application/models/Game_model.php b/codeigniter-develop/application/models/Game_model.php
index 6036a89..9b7c146 100644
--- a/codeigniter-develop/application/models/Game_model.php
+++ b/codeigniter-develop/application/models/Game_model.php
@@ -1,66 +1,52 @@
db->select('*');
+ $this->db->from('game');
$this->db->like('name', $keyword);
- $query = $this->db->get('game');
- return $query->result();
+ $query = $this->db->get();
+ return $query->result_array();
}
-}
- /**
- * 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->join('game_category', 'game_category.gameId = game.id'); // C'était ICI l'erreur !
$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->join('game_genre', 'game_genre.gameId = game.id'); // Et ICI !
$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();
- }
+ public function get_by_id($game_id) {
+ $this->db->select('game.*, developer.name as developer_name, poster.jpeg as poster_url');
+ $this->db->from('game');
+
+ $this->db->join('developer', 'developer.id = game.developerId', 'left');
+ $this->db->join('poster', 'poster.id = game.posterId', 'left');
+
+ $this->db->where('game.id', $game_id);
+
+ $query = $this->db->get();
+ return $query->row_array();
+ }
+
public function ajouter_jeu($titre, $annee, $description, $prix) {
$donnees = array(
@@ -73,11 +59,11 @@ class Game_model extends CI_Model {
}
public function supprimer_jeu($id) {
- return $this->db->delete('game', array('gameId' => $id));
+ return $this->db->delete('game', array('id' => $id));
}
public function get_jeu($id) {
- $leJeu = $this->db->get_where('game', array('gameId' => $id));
+ $leJeu = $this->db->get_where('game', array('id' => $id));
return $leJeu->row_array();
}
@@ -89,10 +75,11 @@ class Game_model extends CI_Model {
'price' => empty($prix) ? NULL : $prix
);
- $this->db->where('gameId', $id);
+ $this->db->where('id', $id);
return $this->db->update('game', $donnees);
}
+
public function get_tous_les_jeux($critere_tri = 'id') {
$tris_autorises = array('id', 'name', 'releaseYear', 'price');
@@ -101,23 +88,12 @@ class Game_model extends CI_Model {
}
$this->db->order_by($critere_tri, 'ASC');
-
$query = $this->db->get('game');
return $query->result_array();
}
-
- public function search_by_title($keyword) {
- $this->db->select('*');
- $this->db->from('game');
-
- $this->db->like('title', $keyword);
-
- $query = $this->db->get();
- return $query->result_array();
+ public function get_all_games() {
+ return $this->get_tous_les_jeux();
}
-
-
-}
-
+}
\ No newline at end of file
diff --git a/codeigniter-develop/application/models/Genre_model.php b/codeigniter-develop/application/models/Genre_model.php
index db1649b..07cbbba 100644
--- a/codeigniter-develop/application/models/Genre_model.php
+++ b/codeigniter-develop/application/models/Genre_model.php
@@ -17,7 +17,7 @@ class Genre_model extends CI_Model {
$this->db->select('genre.*');
$this->db->from('genre');
- $this->db->join('game_genre', 'game_genre.genreId = genre.genreId');
+ $this->db->join('game_genre', 'game_genre.genreId = genre.id');
$this->db->where('game_genre.gameId', $game_id);
diff --git a/codeigniter-develop/application/views/game_detail_view.php b/codeigniter-develop/application/views/game_detail_view.php
index 2244f0f..296bc33 100644
--- a/codeigniter-develop/application/views/game_detail_view.php
+++ b/codeigniter-develop/application/views/game_detail_view.php
@@ -3,62 +3,59 @@
Aucun poster disponible pour ce jeu.
+ +Développeur : = !empty($game['developer_name']) ? html_escape($game['developer_name']) : 'Inconnu' ?>
+ +Prix : = !empty($game['price']) ? html_escape($game['price']) . ' €' : 'Gratuit / Non renseigné' ?>
+ += nl2br(html_escape($game['shortDescription'])) ?>
+ +Développeur : = !empty($game['developer_name']) ? html_escape($game['developer_name']) : 'Inconnu' ?>
- -Prix : = !empty($game['price']) ? html_escape($game['price']) . ' €' : 'Non renseigné' ?>
- -= nl2br(html_escape($game['shortDescription'])) ?>
- -
-
-
-
- = html_escape($cat['name']) ?>
+ Genres associés :
+
+
+
+
- - - - = html_escape($gen['name']) ?> - - - - Aucun genre pour ce jeu. - -
- -