ZF-3306: A Method is not implement in a good way in Zend_Db_Table_Row_Abstract

Issue Type: Bug Created: 2008-05-21T22:33:09.000+0000 Last Updated: 2008-07-21T15:03:55.000+0000 Status: Resolved Fix version(s): - 1.5.3 (28/Jul/08)

Reporter: wanlei (shannonlee) Assignee: Ralph Schindler (ralph) Tags: - Zend_Db_Table

Related issues: Attachments:


This method:

<pre class="highlight">
     * Sets all data in the row from an array.
     * @param  array $data
     * @return Zend_Db_Table_Row_Abstract Provides a fluent interface
    public function setFromArray(array $data)
        foreach ($data as $columnName => $value) {
            $this->$columnName = $value;

        return $this;

This method enable you to set several columns in a single row at once, specified in an associative array that maps the column names to values. You may find this method convenient for setting values both for new rows and for rows you need to update.But it isn't impement in a good way. Let's look at this line: {color:red} $this->$columnName = $value;{color} What it want to do is to use the magic method __set() to set values for the property var $_data.But,in some cases,the argument array may contains a key named the same as some of the property.For example:I have a table filed that it's name is '_data' or others like '_table' , '_connected'. Then this method won't work as we expect it to, and we can hardly notice this unless we read the source code.Why we don't use the magic method __set directly. Like this: {color:red} $this->__set( $columnName , $value){color} It's a better way for this method..


Posted by julien PAULI (doctorrock83) on 2008-05-22T00:27:36.000+0000

At first glance, that seems right to me.

Posted by wanlei (shannonlee) on 2008-05-22T00:42:26.000+0000

?How to say?

Posted by wanlei (shannonlee) on 2008-05-22T20:24:53.000+0000

Outside the class,only public property are consider exist. But,inside the class,all properties include private and protected are consider exist. So, magic method outside the class do not work the same as inside the class.

Posted by Wil Sinclair (wil) on 2008-06-01T14:38:59.000+0000

Please evaluate and categorize as necessary.

Posted by julien PAULI (doctorrock83) on 2008-07-21T15:03:54.000+0000

Fixed at r10267

Have you found an issue?

See the Overview section for more details.


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

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