Changeset 4348

Show
Ignore:
Timestamp:
05/10/08 01:12:54 (14 months ago)
Author:
jwage
Message:

fixes #917 - Fixes hydration issue

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/0.11/lib/Doctrine/Hydrator.php

    r4336 r4348  
    283283        foreach ($data as $key => $value) { 
    284284            // Parse each column name only once. Cache the results. 
    285             if ( ! isset($cache[$key])) { 
    286                 $e = explode('__', $key); 
    287                 $last = strtolower(array_pop($e)); 
    288                 $cache[$key]['dqlAlias'] = $this->_tableAliases[strtolower(implode('__', $e))]; 
    289                 $table = $this->_queryComponents[$cache[$key]['dqlAlias']]['table']; 
    290                 $fieldName = $table->getFieldName($last); 
    291                 $cache[$key]['fieldName'] = $fieldName; 
    292                 if ($table->isIdentifier($fieldName)) { 
    293                     $cache[$key]['isIdentifier'] = true; 
    294                 } else { 
    295                     $cache[$key]['isIdentifier'] = false; 
    296                 } 
    297                 $type = $table->getTypeOfColumn($last); 
    298                 if ($type == 'integer' || $type == 'string') { 
    299                     $cache[$key]['isSimpleType'] = true; 
    300                 } else { 
    301                     $cache[$key]['type'] = $type; 
    302                     $cache[$key]['isSimpleType'] = false; 
    303                 } 
    304             } 
    305  
    306             $map   = $this->_queryComponents[$cache[$key]['dqlAlias']]; 
    307             $table = $map['table']; 
    308             $dqlAlias = $cache[$key]['dqlAlias']; 
    309             $fieldName = $cache[$key]['fieldName']; 
    310  
    311             if (isset($this->_queryComponents[$dqlAlias]['agg'][$fieldName])) { 
    312                 $fieldName = $this->_queryComponents[$dqlAlias]['agg'][$fieldName]; 
    313             } 
    314  
    315             if ($cache[$key]['isIdentifier']) { 
    316                 $id[$dqlAlias] .= '|' . $value; 
    317             } 
    318  
    319             if ($cache[$key]['isSimpleType']) { 
    320                 $rowData[$dqlAlias][$fieldName] = $value; 
    321             } else { 
    322                 $rowData[$dqlAlias][$fieldName] = $table->prepareValue( 
    323                         $fieldName, $value, $cache[$key]['type']); 
    324             } 
    325  
    326             if ( ! isset($nonemptyComponents[$dqlAlias]) && $value !== null) { 
    327                 $nonemptyComponents[$dqlAlias] = true; 
     285            $e = explode('__', $key); 
     286            if(count($e) >= 2) { 
     287              if ( ! isset($cache[$key])) { 
     288                  $last = strtolower(array_pop($e)); 
     289                  $cache[$key]['dqlAlias'] = $this->_tableAliases[strtolower(implode('__', $e))]; 
     290                  $table = $this->_queryComponents[$cache[$key]['dqlAlias']]['table']; 
     291                  $fieldName = $table->getFieldName($last); 
     292                  $cache[$key]['fieldName'] = $fieldName; 
     293                  if ($table->isIdentifier($fieldName)) { 
     294                      $cache[$key]['isIdentifier'] = true; 
     295                  } else { 
     296                      $cache[$key]['isIdentifier'] = false; 
     297                  } 
     298                  $type = $table->getTypeOfColumn($last); 
     299                  if ($type == 'integer' || $type == 'string') { 
     300                      $cache[$key]['isSimpleType'] = true; 
     301                  } else { 
     302                      $cache[$key]['type'] = $type; 
     303                      $cache[$key]['isSimpleType'] = false; 
     304                  } 
     305              } 
     306 
     307              $map   = $this->_queryComponents[$cache[$key]['dqlAlias']]; 
     308              $table = $map['table']; 
     309              $dqlAlias = $cache[$key]['dqlAlias']; 
     310              $fieldName = $cache[$key]['fieldName']; 
     311 
     312              if (isset($this->_queryComponents[$dqlAlias]['agg'][$fieldName])) { 
     313                  $fieldName = $this->_queryComponents[$dqlAlias]['agg'][$fieldName]; 
     314              } 
     315 
     316              if ($cache[$key]['isIdentifier']) { 
     317                  $id[$dqlAlias] .= '|' . $value; 
     318              } 
     319 
     320              if ($cache[$key]['isSimpleType']) { 
     321                  $rowData[$dqlAlias][$fieldName] = $value; 
     322              } else { 
     323                  $rowData[$dqlAlias][$fieldName] = $table->prepareValue( 
     324                          $fieldName, $value, $cache[$key]['type']); 
     325              } 
     326 
     327              if ( ! isset($nonemptyComponents[$dqlAlias]) && $value !== null) { 
     328                  $nonemptyComponents[$dqlAlias] = true; 
     329              } 
    328330            } 
    329331        }