1
0
mirror of synced 2024-12-13 14:56:01 +03:00
doctrine2/manual/codes/Basic Components - Collection - Loading related records.php

21 lines
417 B
PHP
Raw Normal View History

2006-07-27 22:25:18 +04:00
<?php
$users = $conn->query("FROM User");
2006-07-27 22:25:18 +04:00
// 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;
}
?>