コード例 #1
0
ファイル: CusProduct.php プロジェクト: bensonby/csc2720
 function update()
 {
     //update the customized product in the database
     //return true/false on success/failure
     if (!$this->is_saved()) {
         return false;
     }
     $str = dbstr(array('product_id' => $this->info["product_id"], 'quantity' => $this->info["quantity"]), ",", true);
     $result = sql("UPDATE cus_products SET {$str} WHERE id = {$this->info["id"]}");
     if (!$result) {
         return false;
     }
     foreach ($this->attr as $attr => $value) {
         $str = dbstr(array('attr_name' => $attr, 'cus_product_id' => $this->info["id"]), " and ", true);
         $result = sql("UPDATE attrs SET attr_value = '{$this->custom[$attr]}'\n                     WHERE {$str}");
         if (!$result) {
             return false;
         }
     }
     return true;
 }
コード例 #2
0
ファイル: Order.php プロジェクト: bensonby/csc2720
 function remove_product($cus_product)
 {
     if (!$this->is_saved() || !$cus_product->is_saved() || !$cus_product instanceof CusProduct) {
         log2('error: add_product to cart');
         return false;
     }
     $str = dbstr(array('order_id' => $this->info["id"], 'cus_product_id' => $cus_product->get_id()), " AND ", true);
     $result = sql("DELETE FROM order_products WHERE {$str}");
     if (!$result) {
         log2('SQL execution error -- ' . mysql_error());
         return false;
     }
     $this->update();
     $cus_product->delete();
     return true;
 }
コード例 #3
0
ファイル: Image.php プロジェクト: bensonby/csc2720
 function save()
 {
     if (!empty($this->info["id"])) {
         return false;
     }
     $str = dbstr(array("id" => '', "path" => $this->info["path"], "owner" => $this->info["owner"]), ",", false);
     $result = sql("INSERT INTO images VALUES({$str})");
     if (!$result) {
         return false;
     }
     $this->info["id"] = mysql_insert_id();
     return $this->info["id"];
 }