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 $ alex-> gtstudens () , so I have access to Elle's Staines object.

Now my question is how can I get Alex's student ID in the array, for example, call $ alex->; GetStudentsIds () gives it {1,5,7,12, ..}, which are their student IDs.

OK how you wrote it, you add another function in the unit < Pre> public function getStudentsIds () {$ students = $ this- & gt; student; $ StudentIds = []; Foreign Currency ($ student $ $ student) {$ Student ID [=] student-> GetId (); } $ Student ID returned; }

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.

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -