private function _map_posted_data() { $product = new Product(); $product->set_name($_POST['name']); $product->set_description($_POST['description']); $product->set_sell_price($_POST['sell_price']); $product->set_cost_price($_POST['cost_price']); $product->set_photo($_POST['photo']); $product->set_status($_POST['status']); return $product; }
public function get_by_id($id) { $this->db->connect(); $sql = "SELECT id,name,description,sell_price,cost_price,photo,status from tbl_products WHERE id=?"; $stmt = $this->db->initStatement($sql); $stmt->bind_param("i", $id); $stmt->execute(); $stmt->bind_result($id, $name, $description, $sell_price, $cost_price, $photo, $status); while ($stmt->fetch()) { $product = new Product(); $product->set_id($id); $product->set_name($name); $product->set_description($description); $product->set_sell_price($sell_price); $product->set_cost_price($cost_price); $product->set_photo($photo); $product->set_status($status); } $this->db->close(); return $product; }