php - Access to many-to-many relation in array format, symfony2 -
In Symphony we can access many-to-many relationships with Gator Functions, which return objects of array compilation type Are there. For example, to get Alex students we can call Now my question is how can I get Alex's student ID in the array, for example, call OK how you wrote it, you add another function in the unit < Pre> The ideal solution would be to add such a method to a repository and it will only query the student ID for the given object, but this is the easiest solution. $ alex-> gtstudens () , so I have access to Elle's Staines object.
$ alex->; GetStudentsIds () gives it {1,5,7,12, ..}, which are their student IDs.
public function getStudentsIds () {$ students = $ this- & gt; student; $ StudentIds = []; Foreign Currency ($ student $ $ student) {$ Student ID [=] student-> GetId (); } $ Student ID returned; }
Comments
Post a Comment