Skip to content

Instantly share code, notes, and snippets.

@stephenreay
Created August 9, 2012 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephenreay/3306690 to your computer and use it in GitHub Desktop.
Save stephenreay/3306690 to your computer and use it in GitHub Desktop.
<?php
error_reporting(-1);
class T {
private $z;
protected $vars = array();
public function __set($name, $value) {
$this->vars[$name] = $value;
}
}
$file = __DIR__ . DIRECTORY_SEPARATOR . 'test.sqlite';
$pdo = new PDO("sqlite:{$file}");
$statement = $pdo->prepare('select * from t');
$statement->execute();
$results = $statement->fetchAll(PDO::FETCH_CLASS, 'T');
var_dump($results);
CREATE TABLE t(x INTEGER PRIMARY KEY ASC, y, z);
INSERT INTO t (x, y, z) VALUES(1, 'Foo', 'Bar'), (2, 'Fu', 'Bar');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment