1 <?php
2 /**
3 * @package Cart class
4 *
5 * @author TechArise Team
6 *
7 * @email info@techarise.com
8 *
9 */
10
11 include("DBConnection.php");
12 class Cart
13 {
14
15 protected $db;
16 private $_sku;
17 public function setSKU($sku) {
18 $this->_sku = $sku;
19 }
20
21 public function __construct() {
22 $this->db = new DBConnection();
23 $this->db = $this->db->returnConnection();
24 }
25
26 // getAll Product
27 public function getAllProduct() {
28 try {
29 $sql = "SELECT * FROM products";
30 $stmt = $this->db->prepare($sql);
31
32 $stmt->execute();
33 $result = $stmt->fetchAll(\PDO::FETCH_ASSOC);
34 return $result;
35 } catch (Exception $e) {
36 die("Oh noes! There's an error in the query!");
37 }
38 }
39
40 // get Student
41 public function getProduct() {
42 try {
43 $sql = "SELECT * FROM products WHERE sku=:sku";
44 $stmt = $this->db->prepare($sql);
45 $data = [
46 'sku' => $this->_sku
47 ];
48 $stmt->execute($data);
49 $result = $stmt->fetch(\PDO::FETCH_ASSOC);
50 return $result;
51 } catch (Exception $e) {
52 die("Oh noes! There's an error in the query!");
53 }
54 }
55
56 }
57 ?>
58