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
Post a Comment