これは私のドクトリン (1.2) クエリの最初の形式で、ページの下部に返されるものがあります。
$q = Doctrine_Query::create()
->select('i.id, i.time_estimate, i.assigned_to, ts.time_spent')
->from('Model_Issue i')
->innerJoin('i.User_2 user')
->leftJoin('i.IssuesTimeSpent ts')
->where('i.project_id = ?',$project_id);
私はそれでこれをやろうとしています:
$q = Doctrine_Query::create()
->select('i.id, sum(i.time_estimate) as time_estimate, i.assigned_to, sum(ts.time_spent) as time_spent')
->from('Model_Issue i')
->innerJoin('i.User_2 user')
->leftJoin('i.IssuesTimeSpent ts')
->where('i.project_id = ?',$project_id)
->groupBy('assigned_to');
私は、time_estimate と同じように、assigned_to id に関連するすべての問題に費やされたすべての時間の合計で、2 人のユーザー (assigned_to) が戻ってくることを期待していました。
しかし、これは返されたものです。
array
0 =>
array
'id' => string '1' (length=1)
'assigned_to' => string '1' (length=1)
'time_estimate' => string '238' (length=3) <- this is wrong
'time_spent' => string '72' (length=2) <- this is correct i believe
1 =>
array
'id' => string '7' (length=1)
'assigned_to' => string '2' (length=1)
'time_estimate' => string '3' (length=1) <- this is wrong
'time_spent' => string '30' (length=2) <- this is correct i believe
私は正しいことをしようとしていますか? groupby と集計値だけで必要な出力を達成できますか? それとも何か特別なことをする必要がありますか?
よろしく、
NB groupby / sumsの前の完全な配列
array
0 =>
array
'id' => string '1' (length=1)
'time_estimate' => string '4' (length=1)
'assigned_to' => string '1' (length=1)
'IssuesTimeSpent' =>
array
0 =>
array
'id' => string '1' (length=1)
'time_spent' => string '2' (length=1)
1 =>
array
'id' => string '40' (length=2)
'time_spent' => string '1' (length=1)
1 =>
array
'id' => string '2' (length=1)
'time_estimate' => string '6' (length=1)
'assigned_to' => string '1' (length=1)
'IssuesTimeSpent' =>
array
0 =>
array
'id' => string '2' (length=1)
'time_spent' => string '4' (length=1)
1 =>
array
'id' => string '5' (length=1)
'time_spent' => string '3' (length=1)
2 =>
array
'id' => string '6' (length=1)
'time_spent' => string '3' (length=1)
3 =>
array
'id' => string '8' (length=1)
'time_spent' => string '1' (length=1)
4 =>
array
'id' => string '9' (length=1)
'time_spent' => string '1' (length=1)
5 =>
array
'id' => string '10' (length=2)
'time_spent' => string '1' (length=1)
6 =>
array
'id' => string '11' (length=2)
'time_spent' => string '1' (length=1)
7 =>
array
'id' => string '12' (length=2)
'time_spent' => string '2' (length=1)
8 =>
array
'id' => string '13' (length=2)
'time_spent' => string '1' (length=1)
9 =>
array
'id' => string '14' (length=2)
'time_spent' => string '1' (length=1)
10 =>
array
'id' => string '15' (length=2)
'time_spent' => string '1' (length=1)
11 =>
array
'id' => string '16' (length=2)
'time_spent' => string '1' (length=1)
12 =>
array
'id' => string '17' (length=2)
'time_spent' => string '1' (length=1)
13 =>
array
'id' => string '18' (length=2)
'time_spent' => string '1' (length=1)
14 =>
array
'id' => string '19' (length=2)
'time_spent' => string '1' (length=1)
15 =>
array
'id' => string '20' (length=2)
'time_spent' => string '1' (length=1)
16 =>
array
'id' => string '21' (length=2)
'time_spent' => string '1' (length=1)
17 =>
array
'id' => string '22' (length=2)
'time_spent' => string '1' (length=1)
18 =>
array
'id' => string '23' (length=2)
'time_spent' => string '1' (length=1)
19 =>
array
'id' => string '24' (length=2)
'time_spent' => string '1' (length=1)
20 =>
array
'id' => string '25' (length=2)
'time_spent' => string '1' (length=1)
21 =>
array
'id' => string '26' (length=2)
'time_spent' => string '1' (length=1)
22 =>
array
'id' => string '27' (length=2)
'time_spent' => string '1' (length=1)
23 =>
array
'id' => string '28' (length=2)
'time_spent' => string '1' (length=1)
24 =>
array
'id' => string '29' (length=2)
'time_spent' => string '1' (length=1)
25 =>
array
'id' => string '30' (length=2)
'time_spent' => string '1' (length=1)
26 =>
array
'id' => string '31' (length=2)
'time_spent' => string '1' (length=1)
27 =>
array
'id' => string '32' (length=2)
'time_spent' => string '1' (length=1)
28 =>
array
'id' => string '33' (length=2)
'time_spent' => string '1' (length=1)
29 =>
array
'id' => string '34' (length=2)
'time_spent' => string '1' (length=1)
30 =>
array
'id' => string '35' (length=2)
'time_spent' => string '1' (length=1)
31 =>
array
'id' => string '36' (length=2)
'time_spent' => string '1' (length=1)
32 =>
array
'id' => string '37' (length=2)
'time_spent' => string '1' (length=1)
33 =>
array
'id' => string '38' (length=2)
'time_spent' => string '1' (length=1)
34 =>
array
'id' => string '39' (length=2)
'time_spent' => string '3' (length=1)
35 =>
array
'id' => string '42' (length=2)
'time_spent' => string '1' (length=1)
36 =>
array
'id' => string '43' (length=2)
'time_spent' => string '10' (length=2)
2 =>
array
'id' => string '3' (length=1)
'time_estimate' => string '4' (length=1)
'assigned_to' => string '1' (length=1)
'IssuesTimeSpent' =>
array
0 =>
array
'id' => string '3' (length=1)
'time_spent' => string '3' (length=1)
1 =>
array
'id' => string '41' (length=2)
'time_spent' => string '10' (length=2)
3 =>
array
'id' => string '7' (length=1)
'time_estimate' => string '3' (length=1)
'assigned_to' => string '2' (length=1)
'IssuesTimeSpent' =>
array
0 =>
array
'id' => string '7' (length=1)
'time_spent' => string '30' (length=2)