<?phpnamespaceBackEnd\User;require_once'../DB/sqlmanager.class.php';abstractclassUser{protected$id;protected$name;protected$phone;protected$email;protected$address;protected$password;protected$sql;protected$type;publicfunction__construct(string$field,string$value){$this->sql=\BackEnd\DB\SQLManager::getInstance()->getSQLInstance();$bind=array(':search'=>$value);if($field==='login'){$result=$this->sql->select("User","login = :search",$bind);}elseif($field==='id'){$result=$this->sql->select("User","id = :search",$bind);}else{thrownew\Exception('Invalid type to find the user.');}if(empty($result)){thrownew\Exception('User not found');}$this->id=$result[0]['id'];$this->name=$result[0]['name'];$this->phone=$result[0]['phone'];$this->email=$result[0]['email'];$this->address=$result[0]['address'];$this->password=$result[0]['password'];$this->type=$result[0]['type'];}publicfunctiongetId(){return$this->id;}publicfunctiongetName(){return$this->name;}publicfunctiongetPhone(){return$this->phone;}publicfunctiongetEmail(){return$this->email;}publicfunctiongetAddress(){return$this->address;}publicfunctiongetPassword(){return$this->password;}/* No setter for id: we shouldn't change id */publicfunctionsetName(string$name){$this->name=$name;$update=array("name"=>$name);$bind=array(":id"=>$this->id);$sql->update("User",$update,"id = :id",$bind);}publicfunctionsetPhone(string$phone){$this->phone=$phone;$update=array(":phone"=>$phone);$bind=array(":id"=>$this->id);$sql->update("User",$update,":id = $id",$bind);}publicfunctionsetEmail(string$email){$this->email=$email;$update=array(":email"=>$email);$bind=array(":id"=>$this->id);$sql->update("User",$update,":id = $id",$bind);}publicfunctionsetAddress(string$address){$this->address=$address;$update=array(":address"=>$address);$bind=array(":id"=>$this->id);$sql->update("User",$update,":id = $id",$bind);}publicfunctionsetPassword(string$password){$this->password=$password;$update=array(":password"=>$password);$bind=array(":id"=>$this->id);$sql->update("User",$update,":id = $id",$bind);}publicabstractstaticfunctionaddUser(string$login,string$email,string$password,string$name,string$address,string$phone);}
\ No newline at end of file
<?phpnamespaceBackEnd\User;require_once'class/BackEnd/DB/sqlmanager.class.php';abstractclassUser{protected$id;protected$name;protected$phone;protected$email;protected$address;protected$password;protected$sql;protected$type;publicfunction__construct(string$field,string$value){$this->sql=\BackEnd\DB\SQLManager::getInstance()->getSQLInstance();$bind=array(':search'=>$value);if($field==='login'){$result=$this->sql->select("User","login = :search",$bind);}elseif($field==='id'){$result=$this->sql->select("User","id = :search",$bind);}else{thrownew\Exception('Invalid type to find the user.');}if(empty($result)){thrownew\Exception('User not found');}$this->id=$result[0]['id'];$this->name=$result[0]['name'];$this->phone=$result[0]['phone'];$this->email=$result[0]['email'];$this->address=$result[0]['address'];$this->password=$result[0]['password'];$this->type=$result[0]['type'];}publicfunctiongetId(){return$this->id;}publicfunctiongetName(){return$this->name;}publicfunctiongetPhone(){return$this->phone;}publicfunctiongetEmail(){return$this->email;}publicfunctiongetAddress(){return$this->address;}publicfunctiongetPassword(){return$this->password;}/* No setter for id: we shouldn't change id */publicfunctionsetName(string$name){$this->name=$name;$update=array("name"=>$name);$bind=array(":id"=>$this->id);$sql->update("User",$update,"id = :id",$bind);}publicfunctionsetPhone(string$phone){$this->phone=$phone;$update=array(":phone"=>$phone);$bind=array(":id"=>$this->id);$sql->update("User",$update,":id = $id",$bind);}publicfunctionsetEmail(string$email){$this->email=$email;$update=array(":email"=>$email);$bind=array(":id"=>$this->id);$sql->update("User",$update,":id = $id",$bind);}publicfunctionsetAddress(string$address){$this->address=$address;$update=array(":address"=>$address);$bind=array(":id"=>$this->id);$sql->update("User",$update,":id = $id",$bind);}publicfunctionsetPassword(string$password){$this->password=$password;$update=array(":password"=>$password);$bind=array(":id"=>$this->id);$sql->update("User",$update,":id = $id",$bind);}publicabstractstaticfunctionaddUser(string$login,string$email,string$password,string$name,string$address,string$phone);}