1
0
mirror of synced 2024-12-15 07:36:03 +03:00
doctrine2/manual/codes/DQL (Doctrine Query Language) - GROUP BY, HAVING clauses.php

11 lines
312 B
PHP
Raw Normal View History

2006-10-20 23:31:37 +04:00
<?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->getAggregateValue('count') . ' phonenumbers';
}
?>