kfirufk / zend-db-model-generator

Automatically exported from code.google.com/p/zend-db-model-generator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Save fails when updating and ignoreEmptyValuesOnUpdate set to false

GoogleCodeExporter opened this issue · comments

If you try to save an object which has a non-zero primary key and you've
passed in a value of false for ignoreEmptyValuesOnUpdate then the object
won't be updated at all.

This is seen in the save() function of the Mapper.tpl file. It looks like
lines 141 and 142 could just be swapped around. Although, since $data is
required which ever route the code takes, I don't see why you can't just
put "$data = $cls->toArray();" as the first line of the function and then
remove all references to it elsewhere in the function.

Thanks,

James.

Original issue reported on code.google.com by j...@james-thomson.net on 3 Apr 2010 at 4:52

thanks for the feedback. checking this issue.

Original comment by kfirufk@gmail.com on 10 Apr 2010 at 4:03

Modify templates/mapper.tpl toArray() function as follows


public function toArray($cls) {
            <?foreach ($this->_columns as $column):?>if($cls->get<?=$column['capital']?>() !== null) $result['<?=$column['field']?>'] = $cls->get<?=$column['capital']?>();
            <?endforeach;?>

            return $result;
    }


Find attachment for updated mapper.tpl file

Original comment by naseemka...@gmail.com on 28 Jun 2011 at 11:16

Attachments: