Beispiel #1
0
 /**
  * Writes the answer to the database, either updating it
  * when it already exists, or inserting it when it doesn't.
  * 
  * @since 0.1
  * 
  * @return boolean Success indicator
  */
 public function writeToDB()
 {
     $success = parent::writeToDB();
     if ($success) {
         $this->writeAnswersToDB();
     }
     return $success;
 }
Beispiel #2
0
 /**
  * Removes the object from the database.
  * 
  * @since 0.1
  * 
  * @return boolean Success indicator
  */
 public function removeFromDB()
 {
     $dbr = wfgetDB(DB_SLAVE);
     $submissionsForSurvey = $dbr->select('survey_submissions', array('submission_id'), array('submission_survey_id' => $this->getId()));
     $dbw = wfGetDB(DB_MASTER);
     $dbw->begin();
     $sucecss = parent::removeFromDB();
     $sucecss = $dbw->delete('survey_questions', array('question_survey_id' => $this->getId())) && $sucecss;
     $sucecss = $dbw->delete('survey_submissions', array('submission_survey_id' => $this->getId())) && $sucecss;
     foreach ($submissionsForSurvey as $nr => $submission) {
         $sucecss = $dbw->delete('survey_answers', array('answer_submission_id' => $submission->id)) && $sucecss;
         if ($nr % 500 == 0) {
             $dbw->commit();
             $dbw->begin();
         }
     }
     $dbw->commit();
     return $sucecss;
 }