Skip to content

Instantly share code, notes, and snippets.

@Piokaz
Created December 27, 2013 21:57
Show Gist options
  • Save Piokaz/8153203 to your computer and use it in GitHub Desktop.
Save Piokaz/8153203 to your computer and use it in GitHub Desktop.
PHP PDO Default Mysql
try{
$options = array(
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ
);
$DB = new PDO('mysql:host=localhost;dbname=dbname', 'basename', 'password', $options);
}catch(PDOException $e){
exit('Impossible de se connecter !');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment