diff --git a/Prep-TD3/composer.json b/Prep-TD3/composer.json new file mode 100644 index 0000000000000000000000000000000000000000..43bc921b015c344288d9488663df814dfe07aacc --- /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 0000000000000000000000000000000000000000..02e9d4b7556fcb0daf584d7298d6e333cb571752 --- /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 0000000000000000000000000000000000000000..1cf09de9afd3a32fa7dbcb820359dabe6b52dd85 --- /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 0000000000000000000000000000000000000000..645331141549430f7b6f3b47952a318c830fae3a --- /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 0000000000000000000000000000000000000000..2e5684738509714a2f318b30ea990d3520e6cde9 --- /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