Example #1
0
 public function getProductById($id)
 {
     $query = "SELECT p.id as pid, p.name, p.description, p.image_url, \n            p.price, c.id as cid, c.name as cat_name, s.id as sid, s.value as size\n            FROM products p, categories c, sizes s, products_sizes ps \n            WHERE p.id = ps.pid AND s.id = ps.sid AND p.category = c.id AND p.id={$id}";
     $this->connectDb();
     $result = mysql_query($query);
     while ($row = mysql_fetch_array($result)) {
         if (isset($product) == false) {
             $product = new ProductInfo();
             $product->id = $row["pid"];
             $product->name = $row["name"];
             $product->description = $row["description"];
             $product->setImageUrl($row["image_url"]);
             $product->price = $row["price"];
             $category = new ProductCategory();
             $category->id = $row["cid"];
             $category->name = $row["cat_name"];
             $product->category = $category;
         }
         $size = new ProductSize();
         $size->id = $row["sid"];
         $size->value = $row["size"];
         $product->sizes[$size->id] = $size;
     }
     $this->disconnectDb();
     return $product;
 }
Example #2
0
                <?php 
}
?>
            </select>
            
            <div class="lbls">Цена:</div><input required name="fPrice" type="text" placeholder="цена..." id="in_price" /> 
            
            <input name="addItem" type="image" src="/images/admin_additem.png" />
            
            <?php 
if (isset($_POST['addItem_x'])) {
    unset($_POST['addItem_x']);
    $product = new ProductInfo();
    if (is_uploaded_file($_FILES["foto"]["tmp_name"])) {
        $upfile = getcwd() . "\\images\\items\\" . basename($_FILES["foto"]["name"]);
        $product->setImageUrl($_FILES["foto"]["name"]);
        move_uploaded_file($_FILES["foto"]["tmp_name"], $upfile);
    } else {
        echo "Error =(";
    }
    if (is_uploaded_file($_FILES["prefoto"]["tmp_name"])) {
        $upfile = getcwd() . "\\images\\items\\preview_" . basename($_FILES["prefoto"]["name"]);
        move_uploaded_file($_FILES["prefoto"]["tmp_name"], $upfile);
    } else {
        echo "Error =(";
    }
    $product->name = $_POST['fName'];
    $product->category = categoryById($cats, $_POST['fCat']);
    $product->description = $_POST['fText'];
    $product->price = $_POST['fPrice'];
    $ch_sizes = $_POST['fSizes'];