コード例 #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 addProduct(\model\Product $p)
 {
     $smt = $this->conn->prepare("INSERT INTO " . self::$table . " (\n\t\t\t\t\t\t\t\t\t" . self::$c_title . ", \n\t\t\t\t\t\t\t\t\t" . self::$c_filename . ", \n\t\t\t\t\t\t\t\t\t" . self::$c_desc . ", \n\t\t\t\t\t\t\t\t\t" . self::$c_price . ", \n\t\t\t\t\t\t\t\t\t" . self::$c_unique . ") \n\t\t\t\t\t\t\t\t\t\tVALUES ('" . $p->getTitle() . "', \n\t\t\t\t\t\t\t\t\t\t\t'" . $p->getFilename() . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $p->getDesc() . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $p->getPrice() . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $p->getUnique() . "')");
     $smt->execute();
 }