<?php
class Teachers
{
    public $connLink;
    function __construct($url="../manage/connection.php")
    {
        $this->connLink=$url;
    }

    function addTeacher($name,$phone,$address,$gender,$password, $image, $added_by)
    {
        include $this->connLink;

        $add=$connect->query("INSERT INTO teacher (fullname, phone, address, gender, password, image, added_by, status)
        VALUES('$name', '$phone', '$address', '$gender', '$password', '$image', $added_by, 'active')");
        if($add)
        {
            return true;
        }
        else
        {
            return false;
        }
    }

    function getTeacher($id)
    {
        include $this->connLink;
        $getT=$connect->query("SELECT * FROM teacher WHERE id='$id'")->fetch_assoc();
        return $getT;
    }

    function getAllTeachers()
    {
        include $this->connLink;
        $teachers=array();
        $getT=$connect->query("SELECT * FROM teacher");
        while($teacher=$getT->fetch_assoc())
        {
            array_push($teachers, $teacher);
        }
        return $teachers;
    }
    function findTeacher($phone)
    {
        include $this->connLink;
        $getT=$connect->query("SELECT * FROM teacher WHERE phone='$phone'");
        if($getT->num_rows!=0)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    function updateTeacher($name,$tid,$phone,$address,$gender,$password, $image)
    {
        include $this->connLink;
        $update=$connect->query("UPDATE teacher SET fullname='$name', phone='$phone', address='$address', gender='$gender', password='$password', image='$image' WHERE id='$tid'");
        return $update;
        
    }
}
?>