Skip to content

Instantly share code, notes, and snippets.

@kawahara
Created April 3, 2010 01:21
Show Gist options
  • Save kawahara/353970 to your computer and use it in GitHub Desktop.
Save kawahara/353970 to your computer and use it in GitHub Desktop.
<?php
class MyPDOStatement extends PDOStatement
{
protected $pdo;
protected function __construct(PDO $pdo)
{
$this->pdo = $pdo;
}
public function __destruct()
{
unset($this->pdo);
}
}
$dbh = new PDO('mysql:dbname=op3_debian;host=localhost', 'root', '');
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbh->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('MyPDOStatement', array($dbh)));
$stmt = $dbh->prepare("SELECT * from member");
$stmt->execute();
$stmt->closeCursor();
unset($dbh);
unset($stmt);
sleep(10);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment