Skip to content

Instantly share code, notes, and snippets.

View iroegbu's full-sized avatar
🔧
Learning Golang

IROEGBU! iroegbu

🔧
Learning Golang
View GitHub Profile
@iroegbu
iroegbu / gist:5baaed6e1c6d79fff1a2
Created November 5, 2014 17:07
Proper PDO instantiation
<?php
//for PHP 5.3.6+
try {
$dbh = new PDO('mysql:dbname=databasename;host=hostname;charset=utf8', 'username', 'password');
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
} catch (PDOException $e) {
die("Database connection failed.");