From 93cda7e977d9f41ae876bb42ce3c06e34f2b02a9 Mon Sep 17 00:00:00 2001
From: Lebaldesfous <guillaume.huet7@etu.univ-lorraine.fr>
Date: Wed, 17 Mar 2021 18:06:43 +0100
Subject: [PATCH] Prep TD3, Ex2 q1
---
Prep-TD3/composer.json | 14 +++++
Prep-TD3/index.php | 77 +++++++++++++++++++++++++++
Prep-TD3/src/conf/conf.ini | 7 +++
Prep-TD3/src/model/game.php | 19 +++++++
Prep-TD3/src/model/game2character.php | 16 ++++++
5 files changed, 133 insertions(+)
create mode 100644 Prep-TD3/composer.json
create mode 100644 Prep-TD3/index.php
create mode 100644 Prep-TD3/src/conf/conf.ini
create mode 100644 Prep-TD3/src/model/game.php
create mode 100644 Prep-TD3/src/model/game2character.php
diff --git a/Prep-TD3/composer.json b/Prep-TD3/composer.json
new file mode 100644
index 0000000..43bc921
--- /dev/null
+++ b/Prep-TD3/composer.json
@@ -0,0 +1,14 @@
+{
+ "require": {
+ "illuminate/database": "5.5.*",
+ "illuminate/pagination": "5.*",
+ "php": ">=7.0.0",
+ "slim/slim": "3.*"
+ },
+
+ "autoload": {
+ "psr-4": {
+ "PrepTD3\\": "src"
+ }
+ }
+}
\ No newline at end of file
diff --git a/Prep-TD3/index.php b/Prep-TD3/index.php
new file mode 100644
index 0000000..02e9d4b
--- /dev/null
+++ b/Prep-TD3/index.php
@@ -0,0 +1,77 @@
+<?php
+/**
+ * File: 1.php
+ * Creation Date: 04/01/2016
+ * description:
+ *
+ * @author: canals
+ */
+require 'vendor/autoload.php';
+
+
+use PrepTD2\model\annonce;
+use PrepTD2\model\categorie;
+use PrepTD2\model\photo;
+use PrepTD3\model\game as Game;
+use PrepTD2\model\cateannonce;
+use Illuminate\Database\Capsule\Manager as DB;
+
+$config = ['settings' => [
+ 'displayErrorDetails' => true
+]];
+
+$db = new \Illuminate\Database\Capsule\Manager();
+$db->addConnection(parse_ini_file('src/conf/conf.ini'));
+$db->setAsGlobal();
+$db->bootEloquent();
+$container = new \Slim\Container($config);
+$app = new \Slim\App($container);
+
+
+
+/**
+ * configurer la connexion à la base ...
+ */
+/*
+ * logging des requêtes
+ * activer le logging
+ * exécuter les requêtes
+ * afficher le log
+ */
+
+DB::connection()->enableQueryLog();
+
+
+/**
+ * les jeux dont le nom contient Mario
+ */
+
+game::where('name', 'like', '%Mario%')->get();
+
+
+/*
+ * nom des persos du jeu 12342
+ */
+
+foreach (game::find(12342)->game2characters as $c)
+ echo "- perso : " . $c->name ."\n";
+
+
+/**
+ * affichage du log de requêtes
+ */
+
+foreach( DB::getQueryLog() as $q){
+ echo "-------------- \n";
+ echo "query : " . $q['query'] ."\n";
+ echo " --- bindings : [ ";
+ foreach ($q['bindings'] as $b ) {
+ echo " ". $b."," ;
+ }
+ echo " ] ---\n";
+ echo "-------------- \n \n";
+};
+
+
+
+
diff --git a/Prep-TD3/src/conf/conf.ini b/Prep-TD3/src/conf/conf.ini
new file mode 100644
index 0000000..1cf09de
--- /dev/null
+++ b/Prep-TD3/src/conf/conf.ini
@@ -0,0 +1,7 @@
+driver=mysql
+host=localhost
+database=gamepedia
+username=root
+password=
+charset=utf8
+prefix=
\ No newline at end of file
diff --git a/Prep-TD3/src/model/game.php b/Prep-TD3/src/model/game.php
new file mode 100644
index 0000000..6453311
--- /dev/null
+++ b/Prep-TD3/src/model/game.php
@@ -0,0 +1,19 @@
+<?php
+
+
+namespace PrepTD3\model;
+
+
+use PrepTD3\model\game2character;
+
+class game extends \Illuminate\Database\Eloquent\Model
+{
+ protected $table = 'game';
+ protected $primaryKey = 'id';
+ public $timestamps = false;
+
+ public function game2characters()
+ {
+ return $this->hasMany(game2character::class);
+ }
+}
\ No newline at end of file
diff --git a/Prep-TD3/src/model/game2character.php b/Prep-TD3/src/model/game2character.php
new file mode 100644
index 0000000..2e56847
--- /dev/null
+++ b/Prep-TD3/src/model/game2character.php
@@ -0,0 +1,16 @@
+<?php
+
+
+namespace PrepTD3\model;
+
+
+class game2character extends \Illuminate\Database\Eloquent\Model
+{
+ protected $table = 'game2character';
+ protected $primaryKey = 'game_id';
+ public $timestamps = false;
+ public function game()
+ {
+ return $this->belongsTo('annonce');
+ }
+}
\ No newline at end of file
--
GitLab