diff --git a/.gitignore b/.gitignore index 80ae6349242fdac36909c8046cc44d077189bef8..8c67458ebcaacf4276b6b413ffcb84f95d9fff54 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ -.idea/ -.project/ -tp1/src/sql/games_data.sql -tp1/src/sql/games_schema.sql -tp1/vendor/ \ No newline at end of file +*.idea/ +*.project/ +*games_data.sql +*games_schema.sql +*vendor/ +*conf/ \ No newline at end of file diff --git a/tp1/README.md b/README.md similarity index 98% rename from tp1/README.md rename to README.md index 372a091a7d16ee59af65c6a02eb912e31ca8a351..2c2d13d6de82a251d8dc73cd2f02513185518c60 100644 --- a/tp1/README.md +++ b/README.md @@ -1,3 +1,3 @@ -Killian Schuler, Emilien Visentini, Vincent Kbida, Loïc Tardieu - +Killian Schuler, Emilien Visentini, Vincent Kbida, Loïc Tardieu + Ceci est le dépot où sera déposé nos projets \ No newline at end of file diff --git a/tp1/documentation/Thumbs.db b/documentation/Thumbs.db similarity index 100% rename from tp1/documentation/Thumbs.db rename to documentation/Thumbs.db diff --git a/tp1/documentation/modele_relationnel.odt b/documentation/modele_relationnel.odt similarity index 100% rename from tp1/documentation/modele_relationnel.odt rename to documentation/modele_relationnel.odt diff --git a/tp1/documentation/uml.png b/documentation/uml.png similarity index 100% rename from tp1/documentation/uml.png rename to documentation/uml.png diff --git a/tp1/src/sql/request.sql b/sql/request.sql similarity index 93% rename from tp1/src/sql/request.sql rename to sql/request.sql index a58e522a1941f01db574dfcbf51791c74f1be033..418b64551a7046e6c341989da1e9d8e6ef6aa3b7 100644 --- a/tp1/src/sql/request.sql +++ b/sql/request.sql @@ -1,33 +1,33 @@ -SELECT name -from game -where name LIKE '%Mario%' OR alias LIKE '%Mario%'; - - -SELECT name -from company -where location_country LIKE '%Japan%'; - - -SELECT name -from platform -where install_base > 10000000; - -SELECT name -from game -order by name -limit 21173, 442; - - -drop procedure if exists page; - -delimiter // -CREATE PROCEDURE page (IN p INT) -BEGIN - set p = (p-1)*500; - SELECT id, name - from game - order by id - limit p, 500; -END// - +SELECT name +from game +where name LIKE '%Mario%' OR alias LIKE '%Mario%'; + + +SELECT name +from company +where location_country LIKE '%Japan%'; + + +SELECT name +from platform +where install_base > 10000000; + +SELECT name +from game +order by name +limit 21173, 442; + + +drop procedure if exists page; + +delimiter // +CREATE PROCEDURE page (IN p INT) +BEGIN + set p = (p-1)*500; + SELECT id, name + from game + order by id + limit p, 500; +END// + call page(2) \ No newline at end of file diff --git a/tp1/.htaccess b/tp1/.htaccess new file mode 100644 index 0000000000000000000000000000000000000000..6ba3ed23f3d763f9c4e24faf11239825f5c3cbb3 --- /dev/null +++ b/tp1/.htaccess @@ -0,0 +1,19 @@ +RewriteEngine On +# +# RewriteBase indispensable sur webetu : + +# RewriteBase /www/marcolet3u/php-project/ + + +# +# Pour interdire l'accès aux répertoires contenant du code +RewriteRule ^sql(/.|)$ - [NC,F] +RewriteRule ^src(/.|)$ - [NC,F] +RewriteRule ^vendor(/.*|)$ - [NC,F] + +# +# réécriture pour slim + +RewriteCond %{REQUEST_FILENAME} !-d +RewriteCond %{REQUEST_FILENAME} !-f +RewriteRule ^ index.php [QSA,L] \ No newline at end of file diff --git a/tp1/composer.json b/tp1/composer.json index b2e319e3c9340796425717dfc79468bb0ee652cd..46143e2b399f39960c69f7852a7e6d05774e7881 100644 --- a/tp1/composer.json +++ b/tp1/composer.json @@ -1,37 +1,13 @@ -{ - "name": "slim/slim", - "type": "library", - "description": "Slim Framework, a PHP micro framework", - "keywords": ["microframework","rest","router"], - "homepage": "http://github.com/codeguy/Slim", - "license": "MIT", - "authors": [ - { - "name": "Killian Schuler", - "role": "Developer" - }, - { - "name": "Emilien Visentini", - "role": "Developer" - }, - { - "name": "Vincent Kbida", - "role": "Developer" - }, - { - "name": "Loïc Tardieu", - "role": "Developer" - } - ], - "require": { - "php": ">=7.0.0", - "illuminate/database": "5.5.*" - }, - "suggest": { - "ext-mcrypt": "Required for HTTP cookie encryption", - "phpseclib/mcrypt_compat": "Polyfil for mcrypt extension" - }, - "autoload": { - "psr-0": { "Slim": "." } - } -} +{ + "require": { + "illuminate/database": "5.5.*", + "slim/slim": "2.*", + "php": ">=7.0" + }, + + "autoload": { + "psr-4": { + "bdd\\": "./src" + } + } +} \ No newline at end of file diff --git a/tp1/composer.lock b/tp1/composer.lock index fb329556ad7183fc2f1b37a586aa810bb7c5ae09..ac9743ebeda7ec517bf05864f2d3a37abaef7c6b 100644 --- a/tp1/composer.lock +++ b/tp1/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "516743bf32429efd7948e30f637f15b7", + "content-hash": "3e70f60fac24a2aa60eedcd9ce200f65", "packages": [ { "name": "doctrine/inflector", @@ -322,6 +322,51 @@ "description": "Update helper", "time": "2019-07-29T11:03:54+00:00" }, + { + "name": "myclabs/php-enum", + "version": "1.7.2", + "source": { + "type": "git", + "url": "https://github.com/myclabs/php-enum.git", + "reference": "45f01adf6922df6082bcda36619deb466e826acf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/php-enum/zipball/45f01adf6922df6082bcda36619deb466e826acf", + "reference": "45f01adf6922df6082bcda36619deb466e826acf", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": ">=7.1" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35|^5.7|^6.0", + "squizlabs/php_codesniffer": "1.*" + }, + "type": "library", + "autoload": { + "psr-4": { + "MyCLabs\\Enum\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP Enum contributors", + "homepage": "https://github.com/myclabs/php-enum/graphs/contributors" + } + ], + "description": "PHP Enum implementation", + "homepage": "http://github.com/myclabs/php-enum", + "keywords": [ + "enum" + ], + "time": "2019-08-19T13:53:00+00:00" + }, { "name": "nesbot/carbon", "version": "1.39.1", @@ -480,18 +525,65 @@ ], "time": "2017-10-23T01:57:42+00:00" }, + { + "name": "slim/slim", + "version": "2.6.3", + "source": { + "type": "git", + "url": "https://github.com/slimphp/Slim.git", + "reference": "9224ed81ac1c412881e8d762755e3d76ebf580c0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/slimphp/Slim/zipball/9224ed81ac1c412881e8d762755e3d76ebf580c0", + "reference": "9224ed81ac1c412881e8d762755e3d76ebf580c0", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "suggest": { + "ext-mcrypt": "Required for HTTP cookie encryption", + "phpseclib/mcrypt_compat": "Polyfil for mcrypt extension" + }, + "type": "library", + "autoload": { + "psr-0": { + "Slim": "." + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Josh Lockhart", + "email": "info@joshlockhart.com", + "homepage": "http://www.joshlockhart.com/" + } + ], + "description": "Slim Framework, a PHP micro framework", + "homepage": "http://github.com/codeguy/Slim", + "keywords": [ + "microframework", + "rest", + "router" + ], + "time": "2017-01-07T12:21:41+00:00" + }, { "name": "symfony/polyfill-mbstring", - "version": "v1.14.0", + "version": "v1.13.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "34094cfa9abe1f0f14f48f490772db7a775559f2" + "reference": "7b4aab9743c30be783b73de055d24a39cf4b954f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/34094cfa9abe1f0f14f48f490772db7a775559f2", - "reference": "34094cfa9abe1f0f14f48f490772db7a775559f2", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/7b4aab9743c30be783b73de055d24a39cf4b954f", + "reference": "7b4aab9743c30be783b73de055d24a39cf4b954f", "shasum": "" }, "require": { @@ -503,7 +595,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.14-dev" + "dev-master": "1.13-dev" } }, "autoload": { @@ -537,20 +629,20 @@ "portable", "shim" ], - "time": "2020-01-13T11:15:53+00:00" + "time": "2019-11-27T14:18:11+00:00" }, { "name": "symfony/translation", - "version": "v4.4.4", + "version": "v4.4.2", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "f5d2ac46930238b30a9c2f1b17c905f3697d808c" + "reference": "f7669f48a9633bf8139bc026c755e894b7206677" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/f5d2ac46930238b30a9c2f1b17c905f3697d808c", - "reference": "f5d2ac46930238b30a9c2f1b17c905f3697d808c", + "url": "https://api.github.com/repos/symfony/translation/zipball/f7669f48a9633bf8139bc026c755e894b7206677", + "reference": "f7669f48a9633bf8139bc026c755e894b7206677", "shasum": "" }, "require": { @@ -613,7 +705,7 @@ ], "description": "Symfony Translation Component", "homepage": "https://symfony.com", - "time": "2020-01-15T13:29:06+00:00" + "time": "2019-12-12T12:53:52+00:00" }, { "name": "symfony/translation-contracts", @@ -680,7 +772,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=7.0.0" + "php": ">=7.0" }, "platform-dev": [] } diff --git a/tp1/conf/conf.ini b/tp1/conf/conf.ini deleted file mode 100644 index 77280ae3f87afef5da73d9b93ff69f7062187dc0..0000000000000000000000000000000000000000 --- a/tp1/conf/conf.ini +++ /dev/null @@ -1,6 +0,0 @@ -driver=mysql -username=root -host=localhost -database=gamepedia -charset=utf8mb4 -collation=utf8mb4_general_ci \ No newline at end of file diff --git a/tp1/css/style.css b/tp1/css/style.css new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tp1/index.php b/tp1/index.php index 952d93bd45d2584a69878d7fcf005192a4c3c60f..0a3937c35c8cc000dfd9f698cb101453e0df54e4 100644 --- a/tp1/index.php +++ b/tp1/index.php @@ -1,63 +1,70 @@ -<?php - -require_once '../vendor/autoload.php'; - -use bdd\controleur\ControleurRequete; -use Illuminate\Database\Capsule\Manager as DB; -$db = new DB(); -//SI CA NE FONCTIONNE PAS, ENLEVER LES COMMENTAIRES : CES INFOS SONT DEJA DANS LE CONF.INI -//LA LIGNE DU PASSWORD NE DEVRAIT PAS ETRE NECESSAIRE CAR NOUS NOUS CONNECTONS AVEC ROOT, SINON, LA METTRE QUAND MEME -/*$db->addConnection( [ - 'driver' => 'mysql', - 'host' => 'localhost', - 'database' => 'gamepedia', - 'username' => 'user', - //'password' => 'password', - 'charset' => 'utf8', - 'collation' => 'utf8_unicode_ci', - 'prefix' => '' -] );*/ - -// ajout des informations pour se connecter à la base de données -$ini_file = parse_ini_file('../conf/conf.ini'); -$db->addConnection([ - 'driver' => $ini_file['driver'], - 'host' => $ini_file['host'], - 'database' => $ini_file['database'], - 'username' => $ini_file['username'], - 'password' => $ini_file['password'], - 'charset' => $ini_file['charset'], - 'collation' => $ini_file['charset'] . '_unicode_ci', - 'prefix' => '' -]); - -$db->setAsGlobal(); -$db->bootEloquent(); - -session_start(); - -$app = new Slim(); - -$app->get('/', function () { - $v = new HomeView(); - $v->renderHome(); -})->name('accueil'); -$app->get('/ex1/requete1', function () { - $c = new ControleurRequete(); - $c->selectMario(); -})->name('ex1 requete 1'); -$app->get('/ex1/requete2', function () { - $c = new ControleurRequete(); - -})->name('ex1 requete 2'); -$app->get('/ex1/requete3', function () { - $c = new ControleurRequete(); - -})->name('ex1 requete 3'); -$app->get('/ex1/requete4', function () { - $c = new ControleurRequete(); - -})->name('ex1 requete 4'); - - +<?php + +// Import de la class qui a pour but de charger tous les imports du projet +require_once './vendor/autoload.php'; + +// Liste des tous les imports + +use bdd\controllers\ControleurRequete; +use \bdd\views\AccueilView; +use \Illuminate\Database\Capsule\Manager as DB; +use \Slim\Slim; + +// instance de la base de données +$db = new DB(); + +// ajout des informations pour se connecter à la base de données +$ini_file = parse_ini_file('src/conf/conf.ini'); +$db->addConnection([ + 'driver' => $ini_file['driver'], + 'host' => $ini_file['host'], + 'database' => $ini_file['database'], + 'username' => $ini_file['username'], + 'password' => $ini_file['password'], + 'charset' => $ini_file['charset'], + 'collation' => $ini_file['charset'] . '_unicode_ci', + 'prefix' => '' +]); + +// demarage de la basse de donnée +$db->setAsGlobal(); +$db->bootEloquent(); + +// demerage d'un session +session_start(); + +// intance de slim qui a pour but de créer le rootage des urls +$app = new Slim(); + + +/*-----|accueil|-----*/ +$app->get('/', function () { + $v = new AccueilView(); + $v->render(); +})->name('accueil'); +$app->get('/mario', function () { + $v = new ControleurRequete(); + $v->selectMario(); +})->name('mario'); + +$app->get('/japan', function () { + $v = new ControleurRequete(); + $v->selectJapanCompany(); +})->name('japan'); + +$app->get('/platformBase', function () { + $v = new ControleurRequete(); + $v->selectPlatformBase(); +})->name('platformBase'); + +$app->get('/gameNumber', function () { + $v = new ControleurRequete(); + $v->selectGameNumber(); +})->name('gameNumber'); + +$app->get('/page/:p', function ($p) { + $v = new ControleurRequete(); + $v->selectPage($p); +})->name('page'); + $app->run(); \ No newline at end of file diff --git a/tp1/src/controleur/ControleurRequete.php b/tp1/src/controleur/ControleurRequete.php deleted file mode 100644 index 6efe9e420baf4f9796b46fa1dad3432d92a2c651..0000000000000000000000000000000000000000 --- a/tp1/src/controleur/ControleurRequete.php +++ /dev/null @@ -1,55 +0,0 @@ -<?php - -namespace bdd\controleur; - -use bdd\models\company; -use bdd\models\game; -use bdd\models\platform; - -class ControleurRequete{ - public function selectMario(){ - $jeu = \bdd\models\game::select('name')->where('name','like','%Mario%','or','alias','like','%Mario%')->get(); - - $vue = new \bdd\vue\RequeteVue($jeu); - $html = $vue->render(1); - $rs->getBody()->write($html); - return $rs; - - - - } - - public function selectCompanyCountry(){ - $company = \bdd\models\company::select('name')->where('location_country','like','%Japan%')->get(); - $vue = new \bdd\vue\RequeteVue($company); - $html = $vue->render(1); - $rs->getBody()->write($html); - return $rs; - - } - - public function selectPlatformBase(){ - $platform = \bdd\models\platform::select('name')->where('install_base','>','10000000')->get(); - $vue = new \bdd\vue\RequeteVue($platform); - $html = $vue->render(1); - $rs->getBody()->write($html); - return $rs; - } - - public function selectGameNumber(){ - $game = \bdd\models\game::select('name')->orderBy('name')->limit('21173','422')->get(); - $vue = new \bdd\vue\RequeteVue($game); - $html = $vue->render(1); - $rs->getBody()->write($html); - return $rs; - } - - public function selectPage($p){ - $p = ($p-1)*500; - $jeu = \bdd\models\game::select('id','name')->orderBy('id')->limit($p,'500')->get(); - $vue = new \bdd\vue\RequeteVue($jeu); - $html = $vue->render(1); - $rs->getBody()->write($html); - return $rs; - } -} \ No newline at end of file diff --git a/tp1/src/controllers/ControleurRequete.php b/tp1/src/controllers/ControleurRequete.php new file mode 100644 index 0000000000000000000000000000000000000000..2662cd818697f3659308a7c411ac3de6237a4373 --- /dev/null +++ b/tp1/src/controllers/ControleurRequete.php @@ -0,0 +1,42 @@ +<?php + +namespace bdd\controllers; + +use bdd\models\company; +use bdd\models\game; +use bdd\models\platform; + +class ControleurRequete{ + public function selectMario(){ + $jeu = \bdd\models\game::select('name')->where('name','like','%Mario%','or','alias','like','%Mario%')->get(); + + $vue = new \bdd\views\RequeteView($jeu); + $vue->render(1); + } + + public function selectJapanCompany(){ + $company = \bdd\models\company::select('name')->where('location_country','like','%Japan%')->get(); + $vue = new \bdd\views\RequeteView($company); + $vue->render(1); + + } + + public function selectPlatformBase(){ + $platform = \bdd\models\platform::select('name')->where('install_base','>','10000000')->get(); + $vue = new \bdd\views\RequeteView($platform); + $vue->render(1); + } + + public function selectGameNumber(){ + $game = \bdd\models\game::select('name')->orderBy('name')->take(442)->skip(21173)->get(); + $vue = new \bdd\views\RequeteView($game); + $vue->render(1); + } + + public function selectPage($p){ + $p = ($p-1)*500; + $jeu = \bdd\models\game::select('id','name')->orderBy('id')->take(500)->skip($p)->get(); + $vue = new \bdd\views\RequeteView($jeu); + $vue->render(1); + } +} \ No newline at end of file diff --git a/tp1/src/model/company.php b/tp1/src/models/Company.php similarity index 95% rename from tp1/src/model/company.php rename to tp1/src/models/Company.php index 3e824ee28389098b6601f6fd71ec5f747f06c4d2..349eb0055c78e16849e83ca63c14f64db94dbb84 100644 --- a/tp1/src/model/company.php +++ b/tp1/src/models/Company.php @@ -1,15 +1,14 @@ -<?php - - -namespace bdd\models; - -class Company extends \Illuminate\Database\Eloquent\Model -{ - protected $table = 'company'; - protected $primaryKey = 'id'; - public $timestamps = false; - - public function platform(){ - return $this->belongsTo('bdd\models\company', 'id'); - } +<?php + +namespace bdd\models; + +class Company extends \Illuminate\Database\Eloquent\Model +{ + protected $table = 'company'; + protected $primaryKey = 'id'; + public $timestamps = false; + + public function platform(){ + return $this->belongsTo('bdd\models\company', 'id'); + } } \ No newline at end of file diff --git a/tp1/src/model/game.php b/tp1/src/models/Game.php similarity index 95% rename from tp1/src/model/game.php rename to tp1/src/models/Game.php index 33e57401ba5f5d6e03128f341e6e7b6d378e8f8c..146bd9ae4227ccbd99fc62fc2b9f3c35a09dd528 100644 --- a/tp1/src/model/game.php +++ b/tp1/src/models/Game.php @@ -1,15 +1,15 @@ -<?php - - -namespace bdd\models; - -class Game extends \Illuminate\Database\Eloquent\Model -{ - protected $table = 'game'; - protected $primaryKey = 'id'; - public $timestamps = false; - - public function platform(){ - return $this->belongsTo('bdd\models\game', 'id'); - } +<?php + + +namespace bdd\models; + +class Game extends \Illuminate\Database\Eloquent\Model +{ + protected $table = 'game'; + protected $primaryKey = 'id'; + public $timestamps = false; + + public function platform(){ + return $this->belongsTo('bdd\models\game', 'id'); + } } \ No newline at end of file diff --git a/tp1/src/model/platform.php b/tp1/src/models/Platform.php similarity index 95% rename from tp1/src/model/platform.php rename to tp1/src/models/Platform.php index 061a00e26d9b62c5b4052bccd1d1dc7cb1b9bc39..d7f058da7e8c8e3b3707595037aff1756a8a39e7 100644 --- a/tp1/src/model/platform.php +++ b/tp1/src/models/Platform.php @@ -1,15 +1,15 @@ -<?php - - -namespace bdd\models; - -class Platform extends \Illuminate\Database\Eloquent\Model -{ - protected $table = 'platform'; - protected $primaryKey = 'id'; - public $timestamps = false; - - public function platform(){ - return $this->belongsTo('bdd\models\platform', 'id'); - } +<?php + + +namespace bdd\models; + +class Platform extends \Illuminate\Database\Eloquent\Model +{ + protected $table = 'platform'; + protected $primaryKey = 'id'; + public $timestamps = false; + + public function platform(){ + return $this->belongsTo('bdd\models\platform', 'id'); + } } \ No newline at end of file diff --git a/tp1/src/sql/games_data.sql b/tp1/src/sql/games_data.sql deleted file mode 100644 index c1536d9c3a92d945a759e0325bcf11f030a6261f..0000000000000000000000000000000000000000 Binary files a/tp1/src/sql/games_data.sql and /dev/null differ diff --git a/tp1/src/sql/games_schema.sql b/tp1/src/sql/games_schema.sql deleted file mode 100644 index 33b8fa267b7088aa01e9aa1235ee7631b0947987..0000000000000000000000000000000000000000 --- a/tp1/src/sql/games_schema.sql +++ /dev/null @@ -1,191 +0,0 @@ --- Adminer 4.2.2 MySQL dump - -SET NAMES utf8; -SET time_zone = '+00:00'; -SET foreign_key_checks = 0; -SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO'; - -DROP TABLE IF EXISTS `perso`; -CREATE TABLE `perso` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(128) NOT NULL, - `real_name` varchar(128) DEFAULT NULL, - `last_name` varchar(128) DEFAULT NULL, - `alias` varchar(128) DEFAULT NULL, - `birthday` datetime DEFAULT NULL, - `gender` tinyint(4) DEFAULT NULL, - `deck` mediumtext, - `description` longtext, - `first_appeared_in_game_id` int(11) DEFAULT NULL, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NULL DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - -DROP TABLE IF EXISTS `company`; -CREATE TABLE `company` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(128) NOT NULL, - `alias` varchar(128) DEFAULT NULL, - `abbreviation` varchar(64) DEFAULT NULL, - `deck` mediumtext, - `description` longtext, - `date_founded` datetime DEFAULT NULL, - `location_address` varchar(256) DEFAULT NULL, - `location_city` varchar(128) DEFAULT NULL, - `location_country` varchar(128) DEFAULT NULL, - `location_state` varchar(128) DEFAULT NULL, - `phone` varchar(64) DEFAULT NULL, - `website` varchar(256) DEFAULT NULL, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NULL DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - -DROP TABLE IF EXISTS `enemies`; -CREATE TABLE `enemies` ( - `char1_id` int(11) NOT NULL, - `char2_id` int(11) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - -DROP TABLE IF EXISTS `friends`; -CREATE TABLE `friends` ( - `char1_id` int(11) NOT NULL, - `char2_id` int(11) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - -DROP TABLE IF EXISTS `game`; -CREATE TABLE `game` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(128) DEFAULT NULL, - `alias` varchar(128) DEFAULT NULL, - `deck` mediumtext, - `description` longtext, - `expected_release_day` int(11) DEFAULT NULL, - `expected_release_month` int(11) DEFAULT NULL, - `expected_release_quarter` int(11) DEFAULT NULL, - `expected_release_year` int(11) DEFAULT NULL, - `original_release_date` datetime DEFAULT NULL, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NULL DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - -DROP TABLE IF EXISTS `game2character`; -CREATE TABLE `game2character` ( - `game_id` int(11) NOT NULL, - `character_id` int(11) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - -DROP TABLE IF EXISTS `game2genre`; -CREATE TABLE `game2genre` ( - `game_id` int(11) NOT NULL, - `genre_id` int(11) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - -DROP TABLE IF EXISTS `game2platform`; -CREATE TABLE `game2platform` ( - `game_id` int(11) NOT NULL, - `platform_id` int(11) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - -DROP TABLE IF EXISTS `game2rating`; -CREATE TABLE `game2rating` ( - `game_id` int(11) NOT NULL, - `rating_id` int(11) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - -DROP TABLE IF EXISTS `game2theme`; -CREATE TABLE `game2theme` ( - `game_id` int(11) NOT NULL, - `theme_id` int(11) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - -DROP TABLE IF EXISTS `game_developers`; -CREATE TABLE `game_developers` ( - `game_id` int(11) NOT NULL, - `comp_id` int(11) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - -DROP TABLE IF EXISTS `game_publishers`; -CREATE TABLE `game_publishers` ( - `game_id` int(11) NOT NULL, - `comp_id` int(11) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - -DROP TABLE IF EXISTS `game_rating`; -CREATE TABLE `game_rating` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(128) DEFAULT NULL, - `rating_board_id` int(11) DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - -DROP TABLE IF EXISTS `genre`; -CREATE TABLE `genre` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(128) DEFAULT NULL, - `deck` mediumtext, - `description` longtext, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - -DROP TABLE IF EXISTS `platform`; -CREATE TABLE `platform` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(128) NOT NULL, - `alias` varchar(128) DEFAULT NULL, - `abbreviation` varchar(64) DEFAULT NULL, - `deck` mediumtext, - `description` longtext, - `c_id` int(11) DEFAULT NULL, - `install_base` bigint(20) DEFAULT NULL, - `release_date` datetime DEFAULT NULL, - `online_support` tinyint(4) DEFAULT NULL, - `original_price` decimal(10,2) DEFAULT NULL, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NULL DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - -DROP TABLE IF EXISTS `rating_board`; -CREATE TABLE `rating_board` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(128) NOT NULL, - `deck` text, - `description` longtext, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - -DROP TABLE IF EXISTS `similar_games`; -CREATE TABLE `similar_games` ( - `game1_id` int(11) NOT NULL, - `game2_id` int(11) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - -DROP TABLE IF EXISTS `theme`; -CREATE TABLE `theme` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(64) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - --- 2015-12-29 15:37:32 diff --git a/tp1/src/views/AccueilView.php b/tp1/src/views/AccueilView.php new file mode 100644 index 0000000000000000000000000000000000000000..bdaa09ccc874003286e0d0c7240117da33c40e4a --- /dev/null +++ b/tp1/src/views/AccueilView.php @@ -0,0 +1,38 @@ +<?php + +namespace bdd\views; + +use Slim\Slim; + +class AccueilView +{ + + protected $app; + + public function __construct() + { + $this->app = Slim::getInstance(); + } + + public function render() + { + $baseURL = $_SERVER['REQUEST_URI']; + $url1 = $this->app->urlFor("mario"); + $url2 = $this->app->urlFor("japan"); + $url3 = $this->app->urlFor("platformBase"); + $url4 = $this->app->urlFor("gameNumber"); + $url5 = $baseURL . "page/1"; + $html = <<<HTML +<h1>Page d'accueil</h1> +<p> +lien:<br> +<a href=$url1>$url1</a><br> +<a href=$url2>$url2</a><br> +<a href=$url3>$url3</a><br> +<a href=$url4>$url4</a><br> +<a href=$url5>$url5</a><br> +</p> +HTML; + echo $html; + } +} diff --git a/tp1/src/vue/RequeteVue.php b/tp1/src/views/RequeteView.php similarity index 74% rename from tp1/src/vue/RequeteVue.php rename to tp1/src/views/RequeteView.php index 614b8688f3e55de45ddadb734fe67e8a2354966f..4277031d56bc7c5f427803728f4d48ef14c930ab 100644 --- a/tp1/src/vue/RequeteVue.php +++ b/tp1/src/views/RequeteView.php @@ -1,67 +1,71 @@ -<?php - -use Slim\Slim; - -class Requete1 -{ - - protected $tab, $app; - - public function __construct($t) - { - $this->tab = $t; - $this->app = Slim::getInstance(); - } - - public function render($type) - { - switch ($type) { - case 1: - return $this->default(); - break; - default: - return $this->notFound(); - break; - } - } - - private function notFound() - { - $res .= <<<RES - <!doctype html> - - <html lang="fr"> - <head> - <meta charset="utf-8"> - </head> - <body> - <p>data not found</p> - </body> - </html> -RES; - } - - private function default() - { - $res .= <<<RES - <!doctype html> - - <html lang="fr"> - <head> - <meta charset="utf-8"> - </head> - <body> - -RES; - foreach ($this->tab as $key => $value) { - $res .= <<<RES - $key:$value -RES; - } - $res .= <<<RES - </body> - </html> -RES; - return $res; - } -} +<?php + +namespace bdd\views; + +use Slim\Slim; + +class RequeteView +{ + + protected $tab, $app; + + public function __construct($t) + { + $this->tab = $t; + $this->app = Slim::getInstance(); + } + + public function render($type) + { + $html = ""; + switch ($type) { + case 1: + $html = $this->default(); + break; + default: + $html = $this->notFound(); + break; + } + echo $html; + } + + private function notFound() + { + return <<<RES + <!doctype html> + + <html lang="fr"> + <head> + <meta charset="utf-8"> + </head> + <body> + <p>data not found</p> + </body> + </html> +RES; + } + + private function default() + { + $res = <<<RES + <!doctype html> + + <html lang="fr"> + <head> + <meta charset="utf-8"> + </head> + <body> + +RES; + foreach ($this->tab as $key => $value) { + $res .= <<<RES + $key:$value<br> +RES; + } + $res .= <<<RES + </body> + </html> +RES; + return $res; + } +}