My $query->fetch() doesn't work
- by Tae
Question edited following the comments. It still doesn't work.
Hi there,
I'm trying to learn how PDO works, but my script:
$database = new PDO('mysql:host=localhost;dbname=***', '***', '***');
$query = $database->prepare("SELECT nombre,
tecnica,
tamanno,
estado FROM obra WHERE anno = ?");
$query->execute(array('2009'));
while ($item = $query->fetch(PDO::FETCH_ASSOC)) {
$item['nombre'];
}
Prints nothing. If I do:
var_dump($query->fetch())
I get bool(false). After reading lots of examples I can't figure out what I'm doing wrong.
Thanks in advance.