ZF-10413: Wrong docs for Zend_Db_Adapter_Abstract - fetchCol() method

Issue Type: Docs: Problem Created: 2010-09-03T04:08:48.000+0000 Last Updated: 2010-10-26T05:50:45.000+0000 Status: Resolved Fix version(s): - 1.11.0 (02/Nov/10)

Reporter: Andrey Tserkus (zerkella) Assignee: Marc Hodgins (mjh_ca) Tags: - Zend_Db

Related issues: Attachments: - ZF-10413.patch


Php comments doc in Zend_Db_Adapter_Abstract for fetchCol() method states following:

<pre class="highlight">
     * Fetches the first column of all SQL result rows as an array.
     * The first column in each row is used as the array key.
     * @param string|Zend_Db_Select $sql An SQL SELECT statement.
     * @param mixed $bind Data to bind into SELECT placeholders.
     * @return array
    public function fetchCol($sql, $bind = array())

After reading description "The first column in each row is used as the array key" it's expected that this method will return first column values in array where array keys will be equal to array values:

<pre class="highlight">
    val1 => val1,
    val2 => val2,
    val3 => val3,

But despite the description the fetchCol() method returns array indexed in natural order:

<pre class="highlight">
    0 => val1,
    1 => val2,
    2 => val3,

I think it's better to remove "The first column in each row is used as the array key." from description (is it left from initial development?)


Posted by Marc Hodgins (mjh_ca) on 2010-10-25T18:23:07.000+0000

Patch attached.

Posted by Matthew Weier O'Phinney (matthew) on 2010-10-26T05:50:45.000+0000

Patch applied to trunk and 1.11 release branch -- thanks!

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.