Skip to content
This repository was archived by the owner on Jul 20, 2026. It is now read-only.

Commit 303340f

Browse files
committed
unfuck products list
1 parent e956166 commit 303340f

1 file changed

Lines changed: 30 additions & 6 deletions

File tree

src/app/models/product.php

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,33 @@
22

33
class Product
44
{
5-
public $id;
6-
public $name;
7-
public $description;
8-
public $price;
9-
public $supplier_id;
10-
}
5+
6+
private $conn;
7+
8+
public function __construct(PDO $dbConnection) {
9+
$this->conn = $dbConnection;
10+
}
11+
12+
public function create($id, $name, $description, $price, $supplier_id) {
13+
$query = "INSERT INTO product (id, name, description, prince, supplier_id)
14+
VALUES (:id, :name, :description, :price, :supplier_id)";
15+
16+
$stmt = $this->conn->prepare($query);
17+
$stmt->bindValue(":id", $id);
18+
$stmt->bindValue(":name", $name);
19+
$stmt->bindValue(":description", $description);
20+
$stmt->bindValue(":price", $price);
21+
$stmt->bindValue(":supplier_id", $supplier_id);
22+
23+
return $stmt->execute();
24+
}
25+
26+
public function getAll() {
27+
$query = "SELECT * FROM product";
28+
29+
$stmt = $this->conn->prepare($query);
30+
31+
$stmt->execute();
32+
return $stmt->fetchAll(PDO::FETCH_OBJ);
33+
}
34+
}

0 commit comments

Comments
 (0)