views:

29

answers:

1

I have a little problem with the Zend_Db_Stmt. This works:

    $sql = " SELECT * FROM bugs";
    $stmt = $this->_getDb()->query($sql);
    return $stmt->fetchAll();

But I am trying to make sure the PDO gets used to query the database so I tried this:

    $sql = "SELECT * FROM bugs";        
    $stmt = new Zend_Db_Statement_Pdo($this->_getDb(), $sql);
    return $stmt->fetchAll();

And this doesn't work (it returns an empty array). Could you please help me figure this out? The above code works if I use execute() method for UPDATE or INSERT queries but fetchAll() doesn't work.

+3  A: 

You need to execute!

$stmt->execute();
return $stmt->fetchAll();

See more examples in the PHP manual.

Derek Illchuk