Created
November 11, 2016 17:29
-
-
Save tomasfejfar/60af2c230273a4156f80b6f3be65987b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
$pdoOptions = [ | |
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, | |
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8" | |
]; | |
$pdo = new PDO('mysql:host=127.0.0.1;dbname=blog', 'root', '', $pdoOptions); | |
$statement = $pdo->prepare("SELECT * FROM posts"); | |
$statement->execute(); | |
$posts = $statement->fetchAll(PDO::FETCH_ASSOC); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment