added output example of aggregate
This commit is contained in:
parent
f5223491e6
commit
3b1a2e77d4
1 changed files with 14 additions and 11 deletions
|
@ -1,11 +1,14 @@
|
|||
<?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();
|
||||
?>
|
||||
<?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';
|
||||
?>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue