I try throw exception when there is no result in database, here is code:
try {
if (!$stmt->execute()) {
throw new ErrorExeption('there is no row with that id');
}
} catch (ErrorExeption $e) {
echo $e->getMessage();
}
So, when I paste wron Id I cant see the error message. What I am doing wrong?
execute
will only returnfalse
if there's an error. If it there are no matches it will returntrue
, but the first attempt to fetch a row will returnfalse
.