1
0
mirror of synced 2024-12-15 23:56:02 +03:00
doctrine2/manual/codes/Working with objects - Component overview - Collection - Loading related records.php
2007-02-23 20:57:38 +00:00

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;
}
?>