protected function getYourAnswerId($question_id, $student_id) { $student_question = StudentQuestion::model()->find('student_id=:student_id AND question_id=:question_id', array('student_id' => $student_id, 'question_id' => $question_id)); if ($student_question) { return $student_question->answer_id; } else { return 0; } }