Uploaded image for project: 'Doctrine 1'
  1. Doctrine 1
  2. DC-1009

save() also updates fields which should not be


    • Type: Bug
    • Status: Open
    • Priority: Critical
    • Resolution: Unresolved
    • Affects Version/s: 1.2.3
    • Fix Version/s: None
    • Component/s: Query
    • Labels:
    • Environment:
      Windows server 2003 PHP 5.2.17 / XP PRO 32bits XAMPP PHP 5.3.5
      Symfony 1.4.6


      When I want to do a simple update like this :

      $batches = ExamResultsBatchTable::getInstance()->retrieveByExamBatchStatus(ExamResultsBatch::valid_status_code);
      foreach($batches as $batch)
      Only exam_batch_status_id and status_date should be updated (see screenshot before), but columns exam_batch_status_id ,status_date AND exam_subject_id are updated,with the same value (23) (screenshot after_with_save).

      If I run this:
      $toto = Doctrine_Query::create()
      ->update('ExamResultsBatch erb')
      ->set('erb.exam_batch_status_id', 23)
      ->set('erb.status_date', date('Y-m-d'))
      >where('erb.id = ?' , $batch>getId())
      Everything is correctly done.

      here is the simpliest case.

      The same problems are signaled on other tables in the database, but different tables can be impacted by one save() (the execute() query still works fine).

      Example : 2 foreign tables will be updated , even if the save() action should only concern the main table, and one field (which is not a foreign key).
      The corresponding foreign key fields in the 2 foreign tables, will be updated with the value given (here 23).

      Because save() is used in a lot of different places in our app, I need to find a solution to fix save(), or if not possible to override it to run a execute()like query.

      Thanks for your help.
      Don't hesitate to ask if you want more details.


      1. retrieveByExamBatchStatus.php
        1 kB
        Yan Urquiza
      2. schema.yml
        4 kB
        Yan Urquiza
      1. after_with_execute.PNG
        108 kB
      2. after_with_save.PNG
        108 kB
      3. before.PNG
        106 kB



          • Assignee:
            guilhermeblanco Guilherme Blanco
            karibusan Yan Urquiza
          • Votes:
            0 Vote for this issue
            1 Start watching this issue


            • Created: