/**
  * (non-PHPdoc)
  * @see ContestDBObject::writeToDB()
  * @return bool
  */
 public function writeToDB()
 {
     $success = parent::writeToDB();
     if ($success) {
         $contestant = new ContestContestant(array('id' => $this->getField('contestant_id')));
         $contestant->updateVotes();
         $contestant->writeToDB();
     }
     return $success;
 }
 /**
  * Set the database type to use for read operations.
  *
  * @param integer $db
  *
  * @since 0.2
  */
 public function setReadDb($db)
 {
     self::$readDb = $db;
 }
 /**
  * (non-PHPdoc)
  * @see ContestDBObject::insertIntoDB()
  * @return bool
  */
 protected function insertIntoDB()
 {
     $success = parent::insertIntoDB();
     if ($success) {
         $contestant = new ContestContestant(array('id' => $this->getField('contestant_id')));
         $contestant->addToField('comments', 1);
     }
     return $success;
 }
 /**
  * (non-PHPdoc)
  * @see ContestDBObject::insertIntoDB()
  * @return bool
  */
 protected function insertIntoDB()
 {
     wfRunHooks('ContestBeforeContestantInsert', array(&$this));
     $success = parent::insertIntoDB();
     if ($success) {
         $this->onUserSignup();
     }
     return $success;
 }
 /**
  * Remove the contest and all it's linked data from the database.
  *
  * @since 0.1
  *
  * @return boolean Success indicator
  */
 public function removeAllFromDB()
 {
     if (!ContestSettings::get('contestDeletionEnabled')) {
         // Shouldn't get here (UI should prevent it)
         throw new MWException('Contest deletion is disabled', 'contestdeletiondisabled');
     }
     $condition = array('contest_id' => $this->getId());
     $success = ContestChallenge::s()->delete($condition);
     if ($success) {
         $contestantIds = array();
         foreach (ContestContestant::s()->select('id', $condition) as $contestant) {
             $contestantIds[] = $contestant->getId();
         }
         if (count($contestantIds) > 0) {
             $success = ContestComment::s()->delete(array('contestant_id' => $contestantIds)) && $success;
             $success = ContestVote::s()->delete(array('contestant_id' => $contestantIds)) && $success;
         }
         $success = ContestContestant::s()->delete($condition) && $success;
     }
     if ($success) {
         $success = parent::removeFromDB();
     }
     return $success;
 }