示例#1
0
 /**
  * 
  * @param \PDO $pdo
  * @param String $code
  * @return \model\database\views\GameBoxExtended
  */
 public static function retire($pdo, $code)
 {
     $box = \model\database\views\GameBoxExtended::fetchByCode($pdo, $code);
     if (!$box) {
         return null;
     }
     $statement = $pdo->prepare("UPDATE `web_logickehry_db`.`game_box` SET " . "`retired` = 1 " . "WHERE `game_box`.`tracking_code` = :tracking_code");
     if (!$statement->execute(['tracking_code' => $code])) {
         DB_Service::logError($statement->errorInfo(), __CLASS__ . "::" . __FUNCTION__, $statement->queryString);
         return null;
     }
     return $box;
 }
示例#2
0
 private function checkBoxBeforeInsert($code, $game_id)
 {
     if (!$this->user->isSupervisor()) {
         return "Nedostatečná uživatelská oprávnění";
     }
     if (strlen($code) < Tables\GameBox::MIN_CODE_LENGTH) {
         return sprintf("Evidenční kód musí být alespoň %d znaků dlouhý.", Tables\GameBox::MIN_CODE_LENGTH);
     }
     $gameBox = Views\GameBoxExtended::fetchByCode($this->pdo, $code);
     if ($gameBox) {
         $response = "Kód {$code} je v databázi již veden, ";
         $response .= $gameBox->retired ? "je však vyřazený z oběhu" : "náleží hře " . $gameBox->game_name;
         return $response;
     }
     $gameType = $this->gameTypes->fetchById($game_id);
     if (!$gameType) {
         return $this->template['response'] = sprintf("Nebyla nalezena hra %03d", $game_id);
     }
     return false;
 }