1
0
mirror of synced 2024-12-15 15:46:02 +03:00
doctrine2/manual/codes/Basic Components - Collection - Loading related records.php

21 lines
417 B
PHP

<?php
$users = $conn->query("FROM User");
// now lets load phonenumbers for all users
$users->loadRelated("Phonenumber");
foreach($users as $user) {
print $user->Phonenumber->phonenumber;
// no additional db queries needed here
}
// the loadRelated works an any relation, even associations:
$users->loadRelated("Group");
foreach($users as $user) {
print $user->Group->name;
}
?>