1
0
mirror of synced 2024-12-14 07:06:04 +03:00
doctrine2/manual/codes/DQL (Doctrine Query Language) - GROUP BY, HAVING clauses.php
2006-12-22 21:10:14 +00:00

11 lines
294 B
PHP

<?php
// retrieve all users and the phonenumber count for each user
$users = $conn->query("SELECT u.*, COUNT(p.id) count FROM User u, u.Phonenumber p GROUP BY u.id");
foreach($users as $user) {
print $user->name . ' has ' . $user->Phonenumber[0]->count . ' phonenumbers';
}
?>