Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function printStudentsAndClasses()
- {
- $qb = $this->createQueryBuilder('students')
- ->innerJoin('students.classes', 'classes')
- ->getQuery();
- $iterator = function (ClassEntity $classEntity): string {
- return $classEntity->getName();
- };
- /** @var Student $student */
- foreach ($qb->getResult() as $student) {
- echo $student->getName() . ' Classes: ' . \implode(', ', $student->getClasses()->map($iterator)->toArray());
- }
- }
Add Comment
Please, Sign In to add comment