Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doctrine get all field names with associations

I already know how to get field names for entity, but how to get class names for all associations also?

$em->getClassMetadata('Product')->getFieldNames();

This gets class property only, but I expect to get association names inside nested array, for example if I have customer associated to product I would like to get all customer class property names too.

like image 797
slob Avatar asked Apr 16 '14 13:04

slob


1 Answers

You can get the associated field names as well then merge them

$properties = $em->getClassMetadata('YourBundle:Product')->getFieldNames();
$output = array_merge(
              $properties, 
              $em->getClassMetadata('YourBundle:Product')->getAssociationNames()
);
like image 149
Javad Avatar answered Sep 28 '22 02:09

Javad