Zend Framework

Own column name transformation won't work.

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Not an Issue
  • Affects Version/s: 0.9.2
  • Fix Version/s: Next Major Release
  • Component/s: Zend_Db_Table
  • Labels:
    None
  • Fix Version Priority:
    Should Have

Description

Zend Framework changelog says:

ZF-1214 Support a hook for column name transformations in Zend_Db_Table_Row

Thats right, it supports a hook for own transformations, but it does not function because there is still a todo in code.

public function __construct(array $config = array())
    {
        if (isset($config['table']) && $config['table'] instanceof Zend_Db_Table_Abstract) {
            $this->_table = $config['table'];
            $this->_tableClass = get_class($this->_table);
        }

        if (isset($config['data'])) {
            if (!is_array($config['data'])) {
                require_once 'Zend/Db/Table/Row/Exception.php';
                throw new Zend_Db_Table_Row_Exception('Data must be an array');
            }
            // @todo: use setFromArray(), which employs _transformColumn().                 <--- TODO
            $this->_data = $config['data'];
            $this->_cleanData = $this->_data;
        }

        // Retrieve primary keys from table schema
        if ($table = $this->_getTable()) {
            $info = $this->_getTable()->info();
            $this->_primary = (array) $info['primary'];
        }
    }

Because of this todo I cannot use my own column name transformation.

Activity

Hide
Jan Pieper added a comment -

Oh sorry I forgot something This constructor is from Zend_Db_Table_Row_Abstract.

Show
Jan Pieper added a comment - Oh sorry I forgot something This constructor is from Zend_Db_Table_Row_Abstract.
Hide
Bill Karwin added a comment -

There are other places that create instances of Row classes, like the Table fetchAll() method, and createRow(), etc. These methods fetch native column names from the database and provide them to the Row class constructor in the data parameter. They do not provide data arrays with inflected column names.

It's possible that we can have two alternative parameters to the Row constructor, 'data' and 'xData' (real name of this parameter to be decided later). The data parameter would use uninflected column names, and the xData parameter would apply the _transformColumn() method to the column names in keys of the array.

Another possibility is an optional parameter like transform which defaults to true but is set to false when used by internal Table methods. Similar to the 'stored' parameter.

But I'm not going to introduce either of these changes now, since we are virtually on the edge of the ZF 1.0 release. It is too risky that it will break people's code.

Show
Bill Karwin added a comment - There are other places that create instances of Row classes, like the Table fetchAll() method, and createRow(), etc. These methods fetch native column names from the database and provide them to the Row class constructor in the data parameter. They do not provide data arrays with inflected column names. It's possible that we can have two alternative parameters to the Row constructor, 'data' and 'xData' (real name of this parameter to be decided later). The data parameter would use uninflected column names, and the xData parameter would apply the _transformColumn() method to the column names in keys of the array. Another possibility is an optional parameter like transform which defaults to true but is set to false when used by internal Table methods. Similar to the 'stored' parameter. But I'm not going to introduce either of these changes now, since we are virtually on the edge of the ZF 1.0 release. It is too risky that it will break people's code.
Hide
Wil Sinclair added a comment -

Please categorize/fix as needed.

Show
Wil Sinclair added a comment - Please categorize/fix as needed.
Hide
Wil Sinclair added a comment -

Reassigning to Ralph since he's the new maintainer of Zend_Db

Show
Wil Sinclair added a comment - Reassigning to Ralph since he's the new maintainer of Zend_Db
Hide
Ralph Schindler added a comment -

Please see Zend_Db_Table_Row_Abstract::_transformColumn()

If this is not what you are looking for, please reopen.

Show
Ralph Schindler added a comment - Please see Zend_Db_Table_Row_Abstract::_transformColumn() If this is not what you are looking for, please reopen.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved:

Time Tracking

Estimated:
1w
Original Estimate - 1 week
Remaining:
1w
Remaining Estimate - 1 week
Logged:
Not Specified
Time Spent - Not Specified