#1131: $record->get('foo_id') returns related record 'Foo' instead of field 
value
---------------------+------------------------------------------------------
  Reporter:  mahono  |       Owner:  romanb               
      Type:  defect  |      Status:  reopened             
  Priority:  major   |   Milestone:  2.0.0                
 Component:  Record  |     Version:  1.0                  
Resolution:          |    Keywords:  get related record   
  Has_test:  1       |    Mystatus:  Pending Core Response
 Has_patch:  0       |  
---------------------+------------------------------------------------------
Comment (by purnama):

 same for me, should be a bug.

 this patch is work for me:

 {{{
     public function fetchRelatedFor(Doctrine_Record $record)
     {
         $def = $this->definition;
         $a = 1;
         $localFieldName =
 $record->getTable()->getFieldName($this->definition['local']);
         $id = $record->get($localFieldName);

         if (empty($id) || !
 $this->definition['table']->getAttribute(Doctrine::ATTR_LOAD_REFERENCES))
 {
             $related = $this->getTable()->create();
         } else {
             $dql  = 'FROM ' . $this->getTable()->getComponentName()
                  . ' WHERE ' . $this->getCondition();

             $related = $this->getTable()
                             ->getConnection()
                             ->query($dql, array($id))
                             ->getFirst();

             if ( ! $related || empty($related)) {
                 $related = $this->getTable()->create();
             }
         }

 -       $record->set($localFieldName, $related, false);
 +       $record->set($localFieldName,
 $related->get($this->definition['foreign']), false);

         return $related;
     }
 }}}

-- 
Ticket URL: <http://trac.doctrine-project.org/ticket/1131#comment:17>
Doctrine <http://www.phpdoctrine.org>
PHP Doctrine Object Relational Mapper
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"doctrine-svn" group.
 To post to this group, send email to [email protected]
 To unsubscribe from this group, send email to [EMAIL PROTECTED]
 For more options, visit this group at 
http://groups.google.co.uk/group/doctrine-svn?hl=en-GB
-~----------~----~----~----~------~----~------~--~---

Reply via email to