Esempio n. 1
0
 protected function safe($fieldNames)
 {
     foreach ($fieldNames as $_ => $fieldName) {
         if ('string' == gettype($this->{$fieldName})) {
             $value = preg_replace(array('/\\"/'), array('"'), $this->{$fieldName});
             if (get_magic_quotes_gpc()) {
                 $value = stripslashes($value);
             }
             $this->{$fieldName} = Butler::getSQLWrapper()->safe($value);
         } else {
             if ('object' == gettype($this->{$fieldName})) {
                 $class = new ReflectionClass($this->{$fieldName});
                 if ($class->hasMethod('safe')) {
                     $this->{$fieldName}->safe();
                 }
             }
         }
     }
     return $this;
 }
Esempio n. 2
0
 /**
  * @param  $team Team
  * @return mixed
  */
 public function updateTeam($team)
 {
     Butler::getSQLWrapper()->begin();
     $result = Butler::getSQLWrapper()->query(Butler::getQueryManager()->getUpdateTeamSQL($team));
     Butler::getSQLWrapper()->end();
     if ($result) {
         if (!$team->getContestantA()->getName() && $team->getContestantA()->getUser()->isEmpty()) {
             $result = $result && $this->deleteMember($team->getContestantA());
         } else {
             $result = $result && $this->updateTeamMember($team->getContestantA());
         }
         if (!$team->getContestantB()->getName() && $team->getContestantB()->getUser()->isEmpty()) {
             $result = $result && $this->deleteMember($team->getContestantB());
         } else {
             $result = $result && $this->updateTeamMember($team->getContestantB());
         }
         if (!$team->getContestantC()->getName() && $team->getContestantC()->getUser()->isEmpty()) {
             $result = $result && $this->deleteMember($team->getContestantC());
         } else {
             $result = $result && $this->updateTeamMember($team->getContestantC());
         }
         if (!$team->getCoach()->getName() && $team->getCoach()->getUser()->isEmpty()) {
             $result = $result && $this->deleteMember($team->getCoach());
         } else {
             $result = $result && $this->updateTeamMember($team->getCoach());
         }
         if (!$team->getHead()->getName() && $team->getHead()->getUser()->isEmpty()) {
             $result = $result && $this->deleteMember($team->getHead());
         } else {
             $result = $result && $this->updateTeamMember($team->getHead());
         }
     }
     return $result;
 }