I get an empty array when running:
try {
$pdo = new PDO('mysql:127.0.0.1:dbname=mytodo', 'root', 'root');
}
catch (PDOException $e) {
die('Could not connect.');
}
$statement = $pdo->prepare('select * from todos');
$statement->execute();
var_dump($statement->fetchAll());
I've checked the database and running the same query 'select * from todos' returns the results as expected. I've tried using different databases and tables. I always get an empty array. Any ideas as to what's going wrong? I'm running MAMP PRO and get the same issue whatever PHP version I choose.
Any answers or pointers greatly appreciated