Guest User

Untitled

a guest
Feb 20th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. public function printStudentsAndClasses()
  2. {
  3. $qb = $this->createQueryBuilder('students')
  4. ->innerJoin('students.classes', 'classes')
  5. ->getQuery();
  6.  
  7. $iterator = function (ClassEntity $classEntity): string {
  8. return $classEntity->getName();
  9. };
  10.  
  11. /** @var Student $student */
  12. foreach ($qb->getResult() as $student) {
  13. echo $student->getName() . ' Classes: ' . \implode(', ', $student->getClasses()->map($iterator)->toArray());
  14. }
  15. }
Add Comment
Please, Sign In to add comment