Skip to content

Instantly share code, notes, and snippets.

@cythrawll
Created February 20, 2018 22:48
Show Gist options
  • Save cythrawll/e5316ea0c43c64427bfa4e48239ce94a to your computer and use it in GitHub Desktop.
Save cythrawll/e5316ea0c43c64427bfa4e48239ce94a to your computer and use it in GitHub Desktop.
<?php
$options = array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
PDO::ATTR_STRINGIFY_FETCHES => false
);
$db = new PDO('mysql:host=127.0.0.1;dbname=test', $user, $pass, $options);
$stmt = $db->prepare('SELECT * FROM foo');
$stmt->execute();
$results = $stmt->fetchAll();
var_dump($results);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment