php - Getting Doctrine associaton mappings -


i have call looks following:

$foo = $em->getrepository('mybundle:bar')->find($id); 

i able loop on of column/value pairs returned $foo. have found in cases following call gets me information want:

public function getentitycolumnvalues($entity, $em){   $cols = $em->getclassmetadata(get_class($entity))->getcolumnnames();   $values = array();   foreach($cols $col){     $getter = 'get' . $this->underscoretocamelcase($col, true);     $values[$col] = $entity->$getter();   }   return $values; } 

sometimes, however, entity contains information exists doctrine association mappings. info ends out not being set in $values. there way loop on values set in $foo without getting class metadata via getentitycolumnvalues() function have? maybe there way can enhance function mappings? thanks.

you're on right way. $em->getclassmetadata(get_class($entity)) provides classmetadata getters (eg. getassociationmappings)you may need. take look @ them , feel free experience.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -