- création database:
CREATE DATABASE `nomDB`; - Utilisation DB :
USE `nomDB`; - listing database:
SHOW DATABASES; - suppression database:
DROP DATABASE ` nomDB`; - modification database:
ALTER DATABASE `nomDB` CHARACTER SET utf8;
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| html, | |
| body { | |
| margin: 0; | |
| padding: 0; | |
| font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, | |
| Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; | |
| } | |
| header { | |
| padding: 10px; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // src/Entity/Post.php | |
| namespace App\Entity; | |
| use Doctrine\ORM\Mapping as ORM; | |
| /** | |
| * @ORM\Entity(repositoryClass="App\Repository\PostRepository") | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| app.get("/api/movies", (req, res) => { | |
| let sql = "SELECT * FROM movie"; | |
| const sqlValues = []; | |
| if (req.query.rating) { | |
| sql += " WHERE rating = ?"; | |
| sqlValues.push(req.query.rating); | |
| } else if (req.query.genre) { | |
| sql += " WHERE genre = ?"; | |
| sqlValues.push(req.query.genre); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| app.delete("/api/movies/:id", (req, res) => { | |
| const idMovie = req.params.id; | |
| connection.query("DELETE FROM movie WHERE id = ?", [idMovie], (err) => { | |
| if (err) { | |
| console.log(err); | |
| res.status(500).send("Erreur lors de la suppression d'un film"); | |
| } else { | |
| res.sendStatus(200); | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| app.post("/api/movies", (req, res) => { | |
| const formData = req.body; | |
| connection.query("INSERT INTO movie SET ?", formData, (err, results) => { | |
| if (err) { | |
| console.error(err); | |
| res.status(500).send("Erreur lors de la sauvegarde d'un employé"); | |
| } else { | |
| res.sendStatus(200); | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT t.name, COUNT(p.team_id) AS players FROM team t | |
| JOIN player p ON t.id = p.team_id | |
| GROUP BY p.team_id | |
| ORDER BY players DESC; | |
| +------------+---------+ | |
| | name | players | | |
| +------------+---------+ | |
| | Gryffindor | 36 | | |
| | Slytherin | 21 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT w.lastname, w.firstname, role, t.name | |
| FROM player | |
| JOIN wizard w ON wizard_id = w.id | |
| JOIN team t ON team_id = t.id | |
| ORDER BY t.name, role, w.lastname, w.firstname; | |
| +-----------------+-------------+--------+------------+ | |
| | lastname | firstname | role | name | | |
| +-----------------+-------------+--------+------------+ | |
| | Black | Sirius | beater | Gryffindor | | |
| | Brown | Lavender | beater | Gryffindor | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const express = require("express"); | |
| const app = express(); | |
| const port = 3000; | |
| const connection = require("./conf"); | |
| // Routes | |
| app.get("/api/employees", (req, res) => { | |
| connection.query("SELECT * FROM employee", (err, results) => { | |
| if (err) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const express = require("express"); | |
| const app = express(); | |
| const port = 3000; | |
| app.get("/", (req, res) => { | |
| res.send("Bienvenue sur Express !"); | |
| }); | |
| app.get("/api/movies", (req, res) => { | |
| res.send("Récupération de tous les films"); |
NewerOlder