Skip to content

Instantly share code, notes, and snippets.

@EdwardIII
Created December 13, 2012 14:51
Show Gist options
  • Save EdwardIII/4276857 to your computer and use it in GitHub Desktop.
Save EdwardIII/4276857 to your computer and use it in GitHub Desktop.
<?php
$dbh = new PDO('mysql:dbname=db_old;host=localhost', 'tiger', 'secret');
$dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );
$stmt = $dbh->prepare('SELECT * FROM Pages');
$stmt->execute();
// get the row using PDO_FETCH_BOTH (default if not specified as parameter)
// other modes: PDO_FETCH_NUM, PDO_FETCH_ASSOC, PDO_FETCH_OBJ, PDO_FETCH_LAZY, PDO_FETCH_BOUND
$rows = $stmt->fetch(PDO::FETCH_ASSOC);
$c = 1;
foreach ($rows as $row){
print "Row " . $c++ . "\n";
print_r($row);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment