Skip to content

Instantly share code, notes, and snippets.

@Arbagen
Created May 24, 2017 14:33
Show Gist options
  • Save Arbagen/d2888556f2bf1c479d990a6c8d44b255 to your computer and use it in GitHub Desktop.
Save Arbagen/d2888556f2bf1c479d990a6c8d44b255 to your computer and use it in GitHub Desktop.
php true pdo connection
$host = '127.0.0.1';
$db = 'test';
$user = 'root';
$pass = '';
$charset = 'utf8';
$dsn = "mysql:host=$host;dbname=$db;charset=$charset";
$opt = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
];
$pdo = new PDO($dsn, $user, $pass, $opt);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment