Skip to content

Instantly share code, notes, and snippets.

@yvan-sraka
Last active November 6, 2017 17:23
Show Gist options
  • Save yvan-sraka/2238078a8cbfc2a496ec8045f5268f9b to your computer and use it in GitHub Desktop.
Save yvan-sraka/2238078a8cbfc2a496ec8045f5268f9b to your computer and use it in GitHub Desktop.
Example of a SQL query in PHP
<?php
// Connexion à la base de données
try {
$bdd = new PDO('mysql:host=localhost;dbname=mysql;charset=utf8', 'root', 'simplonco');
} catch(Exception $e) {
die('Erreur : '.$e->getMessage());
}
// Execution d'une requête SQL
$reponse = $bdd->query('SHOW DATABASES;');
// Affiche l'objet $response
while ($donnees = $reponse->fetch()) {
var_dump($donnees);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment