コード例 #1
0
 /**
  * 	Method to get new product from old product
  *	@param \model\Product $p
  * 	@return new \model\Product()
  */
 public function getUpdatedProduct(\model\Product $p)
 {
     $this->message = "";
     try {
         return new \model\Product($this->getTitle(), $p->getFilename(), $p->getDesc(), $this->getPrice(), $p->getUnique(), $p->getProductID());
     } catch (\TitleMissingException $e) {
         $this->message = $e->getMessage();
     } catch (\TitleWrongLengthException $e) {
         $this->message = $e->getMessage();
     } catch (\DescMissingException $e) {
         $this->message = $e->getMessage();
     } catch (\DescWrongLengthException $e) {
         $this->message = $e->getMessage();
     } catch (\PriceWrongFormatException $e) {
         $this->message = $e->getMessage();
     } catch (\PriceTooLowException $e) {
         $this->message = $e->getMessage();
     } catch (\PriceMissingException $e) {
         $this->message = $e->getMessage();
     } catch (\UniqueMissingException $e) {
         $this->message = $e->getMessage();
     } catch (\UniqueURLException $e) {
         $this->message = $e->getMessage();
     } catch (\Exception $e) {
         $this->message = $e->getMessage();
     }
 }
コード例 #2
0
 public function updateProduct(\model\Product $p)
 {
     $smt = $this->conn->prepare("UPDATE " . self::$table . " SET " . self::$c_title . " = '" . $p->getTitle() . "', \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . self::$c_desc . " = '" . $p->getDesc() . "', \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . self::$c_price . " = '" . $p->getPrice() . "', \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . self::$c_unique . " = '" . $p->getUnique() . "' WHERE " . self::$c_id . "=" . $p->getProductID() . "");
     $smt->execute();
 }