2009年11月17日星期二

Re: [fw-db] Zend_Db_Table_Row strange behavior -added information

The problem described only occurs if if instantiate the dataobject with a tablename in the options for the constructor. It does not occur if I inherit from Zend_Db_Table_Abstract and specify the tablename as a property.
That will be the reason that not everybody is complaining.

-Bart

Bart McLeod schreef:
Hi all,

I could not find an open issue about this and could not find similar messages on the list, but forgive me if this is a duplicate of anything mentioned earlier.

I have a unit test that tests a dataobject class and it uses a Zend_Db_Table_Row to do updates/inserts.

The strange thing is that after setting a few properties and calling ->save(), one of the column indexes (the last one) is replaced with the tablename....

This is so strange that I thought you guys would be all over the list screaming out in anger, but since you are not, I am probably doing something wrong myself. If not, I will be happy to file an issue and try to fix it.

This is the code:
       $this->DataObject->code = 11;
       $this->DataObject->naam = 'testnaam';
       $this->DataObject->volgnr = 12;
       $this->assertTrue($this->DataObject->save());

This works.
But after that, if I var_dump $this->_row inside the DataObject, I get this:

     ["_cleanData:protected"]=>
     array(3) {
       ["code"]=>
       string(2) "11"
       ["naam"]=>
       string(8) "testnaam"
       ["regio"]=>
       string(2) "12"
     }

The last index should have been 'volgnr', not 'regio', the latter being the name of the table.....

How's that for weird?

If I try to save again, I get the message that volgnr is not in the column list (obvious).

Anyone come to the rescue here?

Regards,

Bart McLeod


--
Bart McLeod
Space Web
Middenlaan 47
6865 VN Heveadorp
The Netherlands
t +31(0)26 3392952
m 06 51 51 89 71
@ info@spaceweb.nl
www.spaceweb.nl
zce logozce PHP 5 logo zce Zend Framework logo

Bart McLeod is a Zend Certified Engineer.

Click to verify!

没有评论: