Function to check if it already exists
public function existsFunction($name){
try{
$command = ("SELECT * FROM function
WHERE function_nm = '$name'");
$num_rows = $this->mysqli->query($command)->num_rows;
if($num_rows < 1){
return false;
}else{
return true;
}
}catch(Exception $err){
echo 'Erro: ', $err->getMessage();
}
}
Function to update
public function editFunction($id, $name, $access, $comment){
try{
if($this->existsFunction($name)){
return "already_exists";
}else{
$command = ("UPDATE function
SET function_nm = '$name',
access_cd = '$access',
function_ds = '$comment'
WHERE function_id = '$id'");
$query = $this->mysqli->query($command);
if(!$query){
return "error";
}else{
return "success";
}
}
}catch(Exception $err){
echo 'Erro: ', $err->getMessage();
}
}