Skip to content

Instantly share code, notes, and snippets.

@ClaudioHenrique
Created January 2, 2015 23:17
Show Gist options
  • Save ClaudioHenrique/c4bec9a61dce214605ba to your computer and use it in GitHub Desktop.
Save ClaudioHenrique/c4bec9a61dce214605ba to your computer and use it in GitHub Desktop.
Conexão com PDO
function getConnection() {
$dbhost="localhost";
$dbuser="root";
$dbpass="root";
$dbname="db_name";
$dbh = new PDO("mysql:host=$dbhost;dbname=$dbname;", $dbuser, $dbpass);
$dbh -> exec("set names utf8");
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $dbh;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment