Use a foreign key in the Classes

Hi,

I try to display an attribute from another classes thanks to the ID:

This is the situation, I have two classes:
-Structure with some attributes (structure_id | structure_name | city_id)
-City with attributes (city_id | city_name)

Now, I try to display all my structure with twig and I get a table with the structure name and the city_id. My problem I want to display the city name thanks to the city_id. How I can reach my goal?

You must have a relation between City and Structure, (ManyToMany, OneToMany,etc). After that if you have Structure object, you can call : $structure->getCity()->getName(). City will be the name of relation.