2009年11月25日星期三

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

Hi Bart
Ok, in that case it sounds like it is a bug in trunk. I do not have the time
to reproduce the problem to confirm it now.

But, as you mention your self, file a bug and suggest a fix if you can.


Bart McLeod wrote:
>
> Hi Jacob,
>
> Sorry for replying so late.
> The var_dump /before /looks like
>
> ["_cleanData:protected"]=>
> array(3) {
> ["code"]=>
> string(2) "11"
> ["naam"]=>
> string(8) "testnaam"
> ["volgnr"]=>
> string(2) "12"
> }
>
> /after/, 'volgnr' is replaced with 'regio', which is the table name.
>
> I am using latest standard version from trunk svn.
>
> I instantiate like this:
> $tableObj = new Zend_Db_Table(array('name' => 'regio'));
>
> I have double checked the names. It would not save the first time, if the
> names were wrong. It does save the first time. Not the second time
> (missing column name)
>
> Again, this doesn't happen if I use a property $_name = 'regio'; for an
> inheritor. So the problem doesn't really bother me, I just think this test
> shows that the documentated behavior is not always happening.
>
> King regards,
>
> Bart McLeod
>
>
>
> oetting schreef:
>> Hi Bart
>>
>> A few questions:
>>
>> What does the var_dump look like before you save the row?
>> Which version of ZF are you using?
>> How exactly do you instantiate the Table object?
>> (Have you double-checked the actual names of the columns in your table?)
>>
>> Regards, Jacob Oettinger
>>
>>
>> Bart McLeod wrote:
>>
>>> 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 <mailto:info@spaceweb.nl>
>>> www.spaceweb.nl <http://www.spaceweb.nl> zce logozce PHP 5 logo zce
>>> Zend Framework logo
>>>
>>> /Bart McLeod is a Zend Certified Engineer./
>>>
>>> Click to verify! <http://www.zend.com/zce.php?c=ZEND004591&r=218204904>
>>>
>>>
>>>
>>>
>>>
>>>
>>
>>
>
> --
> 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 <mailto:info@spaceweb.nl>
> www.spaceweb.nl <http://www.spaceweb.nl> zce logozce PHP 5 logo zce
> Zend Framework logo
>
> /Bart McLeod is a Zend Certified Engineer./
>
> Click to verify! <http://www.zend.com/zce.php?c=ZEND004591&r=218204904>
>
>
>
>
>

--
View this message in context: http://n4.nabble.com/Zend-Db-Table-Row-strange-behavior-tp674691p787384.html
Sent from the Zend DB mailing list archive at Nabble.com.

没有评论: