Created
June 29, 2015 22:12
-
-
Save davepagurek/d567295dea4ea7a6b682 to your computer and use it in GitHub Desktop.
PDO example
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
$DBH = new PDO("mysql:host=$host;dbname=$database", $username, $password); | |
$DBH->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); | |
$STH=$DBH->prepare("SELECT * FROM jokes WHERE id=:joke"); | |
$STH->setFetchMode(PDO::FETCH_ASSOC); | |
$STH->execute(array(":joke" => $joke)); | |
$result = $STH->fetchAll(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment