1
0
mirror of synced 2025-01-08 10:07:10 +03:00
doctrine2/manual/codes/DQL (Doctrine Query Language) - SELECT queries - Aggregate values.php
2007-04-12 17:09:14 +00:00

15 lines
349 B
PHP

<?php
// SELECT u.*, COUNT(p.id) num_posts FROM User u, u.Posts p WHERE u.id = 1 GROUP BY u.id
$query = new Doctrine_Query();
$query->select('u.*, COUNT(p.id) num_posts')
->from('User u, u.Posts p')
->where('u.id = ?', 1)
->groupby('u.id')
->execute();
echo $query->Posts[0]->num_posts . ' posts found';
?>