[Solved] fetchAll helper function using PDO


edit: as the Colonel indicated, apparently this (no longer?) works with LIMIT clauses.


If you’re using simple queries / are not that bothered with type:

function fetchAll(){
   $args = func_get_args();
   $query = array_shift($args);//'SELECT * FROM users WHERE status=? LIMIT ?,?'
   //you'll need a reference to your PDO instance $pdo somewhere....
   $stmt = $pdo->prepare($query);
   $stmt->execute($args);
   return $stmt->fetchAll();
}

4

solved fetchAll helper function using PDO