public function map_data()
 {
     $product = new Product();
     $product->set_product_name($_POST['product_name']);
     $product->set_price($_POST['price']);
     //store file
     $filename = $_FILES['image']['name'];
     $path = ROOT_PATH . "/uploads/";
     move_uploaded_file($_FILES['image']['tmp_name'], $path . $filename);
     $product->set_image($path . $filename);
     $product->set_details($_POST['details']);
     return $product;
 }
 public function get_by_id($id)
 {
     //connect
     $this->db->connect();
     //query
     $sql = "SELECT * FROM products WHERE id=?";
     //prepare
     $stmt = $this->db->initialize($sql);
     //bind
     $stmt->bind_param("i", $id);
     //execute
     $stmt->execute();
     $stmt->bind_result($id, $product_name, $price, $image, $details);
     while ($row = $stmt->fetch()) {
         $product = new Product();
         $product->set_id($id);
         $product->set_product_name($product_name);
         $product->set_price($price);
         $product->set_image($image);
         $product->set_details($details);
     }
     return $product;
 }