Here is my script:
try {
$stmt = $db_con->prepare(" INSERT INTO mytable ( col ) VALUES ( ? ) ");
$inserting = $stmt->execute( array('anything') );
if ( $inserting ) {
echo 'successful';
} else {
echo 'failed';
}
} catch(PDOException $e){
echo 'failed';
}
What's my question: All I want to know, else
and catch
are the same in my script? In other word when else
executes?
I think else
never executes, because if $inserting == false
then it jumps to the catch
block, then else
never run. Am I right? Writing that else
is useless?