コード例 #1
0
ファイル: receipt.php プロジェクト: andregimenez/Capri
 public function save()
 {
     $databaseHelper = new DatabaseHelper();
     if ((int) $this->id > 0) {
         $query = "UPDATE\n                `receipt`\n            SET  \n                `employee` =  '" . $this->employee . "',\n                `priceInVat` =  '" . $this->priceInVat . "',\n                `priceExVat` =  '" . $this->priceExVat . "'\n            WHERE\n                `receipt`.`id` =" . (int) $this->id . ";";
         $databaseHelper->query($query);
     } else {
         $query = "INSERT INTO\n            `receipt` (\n                `employee`,\n                `timestamp`,\n                `priceInVat`,\n                `priceExVat`\n            ) VALUES (\n                '" . $this->employee . "', \n                CURRENT_TIMESTAMP,\n                '" . $this->priceInVat . "',\n                '" . $this->priceExVat . "'\n            );";
         $databaseHelper->query($query);
         $this->id = $databaseHelper->returnLastInsertId();
     }
     return $this->id;
 }
コード例 #2
0
ファイル: receiptProduct.php プロジェクト: andregimenez/Capri
 public function save()
 {
     $databaseHelper = new DatabaseHelper();
     if ($this->getId() > 0) {
         $query = "\n                UPDATE \n                    `receipt_product`\n                SET\n                    `productId` =  '" . $this->getProductId() . "',\n                    `receiptId` =  '" . $this->getReceiptId() . "',\n                    `label` =  '" . $this->getLabel() . "',\n                    `priceInVat` =  '" . $this->getPriceInVat() . "',\n                    `priceExVat` =  '" . $this->getPriceExVat() . "',\n                    `amount` =  '" . $this->getAmount() . "',\n                    `totalPriceInVat` =  '" . $this->getTotalPriceInVat() . "',\n                    `totalPriceExVat` =  '" . $this->getTotalPriceExVat() . "' \n                WHERE  \n                    `receipt_product`.`id` =" . $this->getId() . ";\n                ";
     } else {
         $query = "\n                INSERT INTO \n                `receipt_product` (\n                    `productId` ,\n                    `receiptId` ,\n                    `label` ,\n                    `priceInVat` ,\n                    `priceExVat` ,\n                    `amount` ,\n                    `totalPriceInVat` ,\n                    `totalPriceExVat`\n                ) VALUES (\n                    '" . $this->getProductId() . "',\n                    '" . $this->getReceiptId() . "',\n                    '" . $this->getLabel() . "',\n                    '" . $this->getPriceInVat() . "',\n                    '" . $this->getPriceExVat() . "',\n                    '" . $this->getAmount() . "',\n                    '" . $this->getTotalPriceInVat() . "',\n                    '" . $this->getTotalPriceExVat() . "'\n                );                \n            ";
     }
     $databaseHelper->query($query);
     $this->id = $databaseHelper->returnLastInsertId();
     return $this->id;
 }