I have the following Query with doctrine:
$q = Doctrine_Query::create()
->select("q.id, q.user_id, count(ua.id) as quantity")
->from("question q")
->leftJoin("q.Answers a")
->leftJoin("a.UserAnswers ua")
->groupBy("ua.user_id");
Generated SQL is:
SELECT q.id AS q__id, q.user_id AS q__user_id, COUNT(u.id) AS u__0 FROM question q LEFT JOIN answer a ON q.id = a.question_id LEFT JOIN user_answer u ON a.id = u.answer_id GROUP BY u.user_id
And the result of this query in MySQL is like:
+-------+------------+------+
+ q__id + q__user_id + u__0 +
+-------+------------+------+
+ 1 + 1 + 0 +
+-------+------------+------+
+ 26 + 6 + 2 +
+-------+------------+------+
+ 26 + 6 + 1 +
+-------+------------+------+
Using Doctrine, there is a way to obtain "u__0" column values?
I tried:
$questions = $q->execute();
echo (count($questions));
but the result has only 2 rows (not 3).
How can I get "u__0" column values? (0, 2, 1) using Doctrine?