I found filtering a nice feature especially when you pass all the data coming from a Form as an argument.

Comments

Posted by Adam Jensen (jazzslider) on 2008-02-29T13:05:20.000+0000

Glad to see this has been reported; I was just about to post it myself.

I think Zend_Form has made this issue quite a bit more important. My Zend_Form objects frequently include submit button elements, which get returned back as part of the result of Zend_Form::getValues(). This makes it impossible to use that returned array as the parameter of setFromArray().

Maybe, however, instead of changing the behavior entirely, we should make this "filtering" optional via a new argument for setFromArray(). The logic would go like this:

The codebase has changed a little since the initial report, but this issue remains. I've created this patch that moves array_intersect_key($data, $defaults); out of Zend_Db_Table_Abstract::createRow() and into Zend_Db_Table_Row_Abstract::setFromArray() . setFromArray() is already called by createRow() so moving this line should make the two function consistent.

This patch works in a few of my own test cases.

Posted by Jaka Jancar (jaka) on 2008-08-14T09:32:07.000+0000

+1 vote. Stephen's suggestion (moving the logic into Zend_Db_Table_Row) works for me too.

Posted by Jaka Jancar (jaka) on 2008-08-14T09:38:24.000+0000

Additionally, setFromArray()'s description is a bit misleading: ??Sets all data in the row from an array.?? It does not set all data (i.e. set unspecified columns to null), but only the given columns.