Skip to content

Instantly share code, notes, and snippets.

@rantastic
Created March 21, 2013 18:55
Show Gist options
  • Save rantastic/5215649 to your computer and use it in GitHub Desktop.
Save rantastic/5215649 to your computer and use it in GitHub Desktop.
PHP: PDO select statement return array
$stmt = $db->prepare('SELECT * FROM tablename WHERE colname = ?');
$stmt->execute(array($variable));
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
if($stmt->rowCount()>0){
foreach($results as $result){
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment