I’m using PDO with a try…catch statement. I want to confirm with you guys if I understand this correctly. Do I put $dbhandler = NULL before the throw
$dbhandler = NULL;
if(!$sthandler->rowCount()) throw new invalidUplineException();
or after the throw
if(!$sthandler->rowCount()) throw new invalidUplineException();
$dbhandler = NULL;
When a exception is thrown, the script execution jumps to the next matching
catch()block (if you are inside atry{}block) or stops completely (if the exception is not caught). This behaviour is not related to PDO, it’s how exceptions work in all languages that support them. Thus the$dbhandler = NULL;part in your second example will never be executed. Here’s a simple test you can run: