<?php 
    class Deduction{
        private $db;
    public function __construct($db)
    {
        $this->db  = $db;
    }
    function maxD(){
        $db = $this->db;
        $maxsql= $db->prepare("SELECT max(de_id) as maxd FROM deduction");
        $maxsql->execute();
      if($maxsql->rowCount()>0){$row = $maxsql->fetch(PDO::FETCH_ASSOC);
            $maxD = $row['maxd']+1;} else {$maxD = 1 ; }
            return $maxD ;
    }
    function create($contract_id,$money,$description,$father){
        $db = $this->db ;
        $sql = $db->prepare("INSERT INTO deduction()");
    }
    function update($de_id,$money,$description){
        $db = $this->db;
        $sql = $db->prepare("UPDATE deduction set money_de = ? , description = ? where de_id = ?");
        $sql->bindParam(1,$money);
        $sql->bindParam(2,$description);
        $sql->bindParam(3,$de_id);
        if($sql->execute()){
            return true;
        }else{
            return false;
        }
    }


    }// deduction class
?>