/** * This method accepts a question id and finds if the question has any answer posted. * Returns true if question does not have any answers posted to it. * Returns false if question have any answers posted to it. * * * @param string $questionId * @return true || false */ public static function isUpdateable($questionId) { $jukeboxAnswers = JukeboxAnswers::model()->find('jukebox_question_id=:questionId', array(':questionId' => $questionId)); if ($jukeboxAnswers) { return false; } else { return true; } }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = JukeboxAnswers::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
/** * This method accepts the answer id and returns the answer. * returns 1 if successfull * returns 0 if not successfull * * @param string $answerId * @return 1 || 0. */ public static function getJukeboxAnswerById($answerId) { return JukeboxAnswers::model()->findByPk($answerId); }