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

Issue Type: Improvement Created: 2007-05-24T10:52:51.000+0000 Last Updated: 2008-03-21T16:25:22.000+0000 Status: Resolved Fix version(s): - 1.5.0 (17/Mar/08)

Reporter: Bill Karwin (bkarwin) Assignee: Simon Mundy (peptolab) Tags: - Zend_Db

Related issues: Attachments:


Kirill Balyasnikov writes:

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

<pre class="highlight">
$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.


Posted by Bill Karwin (bkarwin) on 2007-05-24T10:54:50.000+0000

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

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

Posted by Simon Mundy (peptolab) on 2008-01-26T17:48:03.000+0000

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

Posted by Simon Mundy (peptolab) on 2008-01-26T18:18:14.000+0000

Resolved in trunk r7649

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.