<?php
class Investment{
    // database connection and table name
    private $conn;
    private $table_name = "investment";
 
    // object properties
	public $id;
	public $investor_id;
	public $date;
	public $amount;
	public $entry_by;
	public $entry_date_time;

	// public $deposit_by;
	// public $df;
	// public $dt;
 
    public function __construct($db){
        $this->conn = $db;
    }

	function getAllRows(){
		$query = "SELECT * FROM " . $this->table_name . " WHERE investor_id =:investor_id ORDER BY id";
		$stmt = $this->conn->prepare($query);
		
		$stmt->bindParam(":investor_id", $this->investor_id);
		$stmt->execute();
		return $stmt;
	}

	function delete(){
		$query = "DELETE FROM " . $this->table_name . " WHERE id = ?";
		$stmt = $this->conn->prepare($query);
		$this->id = htmlspecialchars(strip_tags($this->id));
		$stmt->bindParam(1, $this->id);
		if($stmt->execute()){
			return true;
		}
		return false;
	}
	
	function create(){
		$query = "INSERT INTO " . $this->table_name . " SET investor_id=:investor_id,date=:date,amount=:amount, entry_by=:entry_by";
		$stmt = $this->conn->prepare($query);
	 
		$stmt->bindParam(":investor_id", $this->investor_id);
		$stmt->bindParam(":date", $this->date);
		$stmt->bindParam(":amount", $this->amount);
		$stmt->bindParam(":entry_by", $this->entry_by);
	 
		if($stmt->execute()){
			return true;
		}	 
		return false;
	}	


}
?>