Hello:
I've just started learning OOPHP, and I love it!!! However, I've come across a strange issue.
I'm trying to return a boolean value from my ternary statement. It will not return the boolean. I can return a string literal, an integer, anything else you can think of, but not a boolean.
I'm curious if someone could explain why. Here's the code:
// delete the row required
$sql = "DELETE FROM $table WHERE id = $id";
if($conn -> query($sql)) {
try {
$num = ($conn -> affected_rows > 0) ? true : false;
return $num;
} catch (Exception $e) {
echo '<br>Caught exception: ', $e -> getMessage(), '<br>';
}
} else {
return false;
}
Any help is appreciated. Thank you so much in advance.