Skip to content

Instantly share code, notes, and snippets.

@norv
Created June 3, 2012 18:54
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 norv/2864616 to your computer and use it in GitHub Desktop.
Save norv/2864616 to your computer and use it in GitHub Desktop.
<?php
class PDOConnection extends \PDO
{
// ... stuff
function fetch_all_as_whatever($query, $params)
{
// prepare, clean, whatnot
// retrieve a statement
$statement = $this->prepare($query);
$statement->execute($params);
$rows = $statement->fetchAll(\PDO::FETCH_CLASS);
// stay on the safe side
$statement->closeCursor();
unset($statement);
return($rows);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment