Skip to content

Instantly share code, notes, and snippets.

@pmjones
Created February 21, 2014 19:37
Show Gist options
  • Save pmjones/9141801 to your computer and use it in GitHub Desktop.
Save pmjones/9141801 to your computer and use it in GitHub Desktop.
<?php
$pdo = new PDO('sqlite::memory:');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->exec('CREATE TABLE foo (bar VARCHAR(20))');
$sth = $pdo->prepare('INSERT INTO foo (bar) VALUES (:bar)');
var_dump($sth);
$sth->execute(array('bar' => 'bar'));
$sth->execute(array('bar' => null));
$sth = $pdo->prepare('SELECT * FROM foo');
$sth->execute($bind);
$rows = $sth->fetchAll(PDO::FETCH_ASSOC);
var_dump($rows);
@scoates
Copy link

scoates commented Feb 21, 2014

array(2) {
  [0]=>
  array(1) {
    ["bar"]=>
    string(3) "bar"
  }
  [1]=>
  array(1) {
    ["bar"]=>
    NULL
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment