Changeset 4356

Show
Ignore:
Timestamp:
05/10/08 05:07:36 (8 months ago)
Author:
jwage
Message:

fixes #997

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/0.11/lib/Doctrine/Data/Export.php

    r4094 r4356  
    4747     * doExport 
    4848     * 
     49     * FIXME: This function has ugly hacks in it for temporarily disabling INDEXBY query parts of tables  
     50     * to export. 
     51     * 
     52     * Update from jwage: I am not sure if their is any other better solution for this. It may be the correct 
     53     * solution to disable the indexBy settings for tables when exporting data fixtures. Maybe a better idea  
     54     * would be to extract this functionality to a pair of functions to enable/disable the index by settings  
     55     * so simply turn them on and off when they need to query for the translations standalone and don't need  
     56     * it to be indexed by the lang. 
     57     * 
    4958     * @return void 
    5059     */ 
     
    6372        $models = Doctrine::initializeModels($models); 
    6473 
     74        // temporarily disable indexBy query parts of selected and related tables 
     75        $originalIndexBy = array(); 
     76        foreach ($models AS $name) { 
     77          $table = Doctrine::getTable($name); 
     78          if (!is_null($indexBy = $table->getBoundQueryPart('indexBy'))) { 
     79            $originalIndexBy[$name] = $indexBy; 
     80            $table->bindQueryPart('indexBy', null); 
     81          } 
     82        } 
     83 
    6584        foreach ($models AS $name) { 
    6685            if ( ! empty($specifiedModels) AND ! in_array($name, $specifiedModels)) { 
     
    7392                $data[$name] = $results; 
    7493            } 
     94        } 
     95 
     96        // Restore the temporarily disabled indexBy query parts 
     97        foreach($originalIndexBy AS $name => $indexBy) { 
     98            Doctrine::getTable($name)->bindQueryPart('indexBy', $indexBy); 
    7599        } 
    76100