$dbh = new PDO ("sqlite:/Library/WebServer/Documents/nwind2009.db3");
$sql = "SELECT * FROM Customers";
print_r($dbh->query($sql));
This returns:
PDOStatement Object ( [queryString] => SELECT * FROM Customers )
but if I do:
foreach ($dbh->query($sql) as $row) {
echo $row['CompanyName'];
}
I get the data.
Why doesn't print_r show the database results? What special thing is happening in the foreach? I thought print_r showed me the array and that that was what I was doing in my foreach.
Thanks.