answer_id = $questionAnswer->getAnswerId(); $qa->question_id = $questionAnswer->getQuestionId(); $qa->choice = $questionAnswer->getChoice(); try { $qa->save(); $questionAnswer->setId($qa->id); } catch(Doctrine_Exception $e) { throw new App_Dao_Exception('Error in saving QuestionAnswer', $e); } } public function findQuestionAnswer($id) { } public function fetchAnswersTo(Quiz_QuestionAnswer $questionAnswer, $possibleChoices=array()) { $q = Doctrine_Query::create() ->select('answer_id') ->from('QuestionAnswer') ->where('question_id = ? AND choice = ?', array( $questionAnswer->getQuestionId(), $questionAnswer->getChoice() )) ->groupBy('answer_id') ->orderBy('COUNT(answer_id)'); if(count($possibleChoices) > 0) $q->whereIn('answer_id', $possibleChoices); try { $answers = $q->execute(); } catch(Doctrine_Exception $e) { throw new App_Dao_Exception('Error fetching answers', $e); } $ids = array(); foreach($answers as $ans) $ids[] = $ans['answer_id']; return $ids; } }