Récupérer données d'une relation n n
Bonjour à tous,
je viens de me mettre à Symfony et j'ai du mal avec les relations n n.
Dans ma base de donnée ci dessous, un "profile" peut avoir plusieurs "hobby" et un "hobby" peut appartenir à plusieurs "profile".
Schéma Yaml :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
Hobby:
columns:
id: { type: integer, notnull: true, primary: true, autoincrement: true}
name: { type: string(255), notnull: true }
Profile:
columns:
id: { type: integer, notnull: true, primary: true, autoincrement: true }
name: { type: string(255), notnull: true }
ProGetHob:
columns:
profile_id: { type: integer, primary: true }
hobby_id: { type: integer, primary: true }
relations:
Profile: { onDelete: CASCADE, local: profile_id, foreign: id }
Hobby: { onDelete: CASCADE, local: hobby_id, foreign: id } |
J'aimerai pouvoir récupérer tous les hobby d'un profil en appliquant la méthode ci-dessous en tant que collection:
Code:
1 2
|
$hobbies = $profile->getProGetHob(); |
Mais l'erreur suivante s'affiche : Unknown record property / related component "pro_get_hob" on "Profile"
Est-il possible d'utiliser cette méthode ?
sinon comment faire ?
Merci à tous.