Beispiel #1
0
 /**
  * Gets the html-representation of the beer
  *
  * @return string
  */
 private function getBeerHTML()
 {
     $image = $this->beer->getImageURL();
     $html = '<div class="row">
                 <div class="col-md-4">
                     <img src="' . $image . '" alt="BeerImage" class="img-circle beer-image img-responsive">
                 </div>
                 <div class="col-md-8">
                     <div><b>Namn: </b><p>' . $this->beer->getName() . '</p></div>
                     <div><b>Bryggeri:</b><p>' . $this->beer->getBrewery() . '</p></div>
                     <div><b>Abv: </b><p>' . $this->beer->getAbv() . '</p></div>
                     <div><b>Land: </b><p>' . $this->beer->getCountry() . '</p></div>
                     <div><b>Serveringstyp: </b><p>' . $this->beer->getServingType() . '</p></div>
                     <div><b>Volym: </b><p>' . $this->beer->getVolume() . ' cl</p></div>
                 </div>
             </div>';
     return $html;
 }
Beispiel #2
0
 /**
  * Updates a post in the table beers
  *
  * @param Beer $beer
  * @throws \DataBaseException
  * @throws \Exception
  */
 public function updateBeer(\model\Beer $beer)
 {
     try {
         $stmt = $this->conn->prepare("CALL update_beer(?, ?, ?, ?, ?, ?, ?, ?)");
         if (!$stmt) {
             throw new \DataBaseException($this->conn->error);
         }
         $id = $beer->getId();
         $name = $beer->getName();
         $abv = $beer->getAbv();
         $manufacturer = $beer->getBrewery();
         $imageurl = $beer->getImageURL();
         $country = $beer->getCountry();
         $volume = $beer->getVolume();
         $servingType = $beer->getServingType();
         $stmt->bind_param("ssdsssds", $id, $name, $abv, $manufacturer, $imageurl, $country, $volume, $servingType);
         $stmt->execute();
     } catch (\DataBaseException $e) {
         if (\Settings::DEBUG_MODE) {
             throw $e;
         } else {
             error_log($e->getMessage() . "\n", 3, \Settings::ERROR_LOG);
             echo "Something went wrong when connecting to the database";
             die;
         }
     }
 }