Created
January 2, 2015 23:17
-
-
Save ClaudioHenrique/c4bec9a61dce214605ba to your computer and use it in GitHub Desktop.
Conexão com PDO
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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