ZF-1428: Adapter fetchAll() method should have an optional fetch-mode argument


Kirill Balyasnikov writes:

Why is it not possible to specify fetch mode directly in method calls such as:

$connection->fetchAll($queryString, $bindArray, PDO::FETCH_ASSOC);

It's not very convinient to call setFetchMode and getFetchMode before and after the call to restore previous state.

For example i have 10 methods in different classes and sometimes i need to get results as numeric array and sometimes as assoc array. So to be sure everything is working ok i have to setFetchMode before every fetchXXX call.


The workaround you can use now is to write a loop to fetch(), and in the fetch() method you can specify the fetch mode:

$stmt = $connection->query($queryString, $bindArray);
while ($data[] = $stmt->fetch(PDO::FETCH_ASSOC)) { }

Sounds reasonable to me. I'll commit this soon.

Resolved in trunk r7649