2008年12月11日星期四

[fw-db] Zend_Db_Row toarray() is detected as string type?

For some reason, the output of the following code snippet:

// from within a domain model
$table = $this->getTable('Users'); // returns TDG
$row = $table->fetchRow($table->select()->where('id =
?',$request->getParam('id'))); // returns Zend_Db_Row_Abstract
$this->getForm()->setDefaults($row->toArray(),
explode(',',$row->privileges));

is detected as a string by Zend_Form::setDefaults(), returns the following
error:

Catchable fatal error: Argument 1 passed to Zend_Form::setDefaults() must be
an array, string given, called in
/home/rvdavid/workspace2/athena/library/Zend/Form.php on line 1214

As a workaround, I've removed the array type hint from the Zend_Form
setDefalult method, but only after 90 minutes of trying to figure it out.

The strange thing is - if I go to the toArray() method of the Row abstract
class and changed it to return array() instead of $this->_data, then it
works fine. looked all over the code to see how it was coming about and it
all seemed pretty clean.

Don't have time to provide more info, but it's there for the asking if
anyone is interested.

...

-----

R. Villar David
Lead Developer, DevProducts Pty Ltd
p: +61 2 9648 3777 f: +61 2 9648 6988
w: http://www.devproducts.com
--
View this message in context: http://www.nabble.com/Zend_Db_Row-toarray%28%29-is-detected-as-string-type--tp20954917p20954917.html
Sent from the Zend DB mailing list archive at Nabble.com.

没有评论: