Development

#3526: DoctrineFormGeneratedTemplate_save.diff

You must first sign up to be able to contribute.

Ticket #3526: DoctrineFormGeneratedTemplate_save.diff

File DoctrineFormGeneratedTemplate_save.diff, 1.4 kB (added by thomas.s, 8 months ago)

Assign the primary key the doctrine way.

  • /Users/thomas/Workspace/erfahrung/symfony11/data/generator/myDoctrineForm/default/template/myDoctrineFormGeneratedTemplate.php

    old new  
    104104    $q = Doctrine_Query::create() 
    105105          ->delete() 
    106106          ->from('<?php echo $relation['refTable']->getOption('name') ?> r') 
    107           ->where('r.<?php echo $relation->getLocalFieldName() ?>', $this->object->identifier()) 
     107          ->where('r.<?php echo $relation->getLocalFieldName() ?> = ?', current($this->object->identifier())) 
    108108          ->execute(); 
    109109 
    110110    $values = $this->getValue('<?php echo $this->underscore($relation['refTable']->getOption('name')) ?>_list'); 
     
    113113      foreach ($values as $value) 
    114114      { 
    115115        $obj = new <?php echo $relation['refTable']->getOption('name') ?>(); 
    116         $obj-><?php echo $relation->getLocalFieldName() ?> = $this->object->getPrimaryKey(); 
     116        $obj-><?php echo $relation->getLocalFieldName() ?> = current($this->object->identifier()); 
    117117        $obj-><?php echo $relation->getForeignFieldName() ?> = $value; 
    118118        $obj->save(); 
    119119      }