Multi-line SQL query doesn't throw PDOException, I can't detect execution failure

Hi, thanks for the answer. The reason why I want to catch the Exception is that I’m calling the controller method as a Shell task that inserts many records on the database and I need to know of some of the inserts failed.

I also want to wrap it in a transaction, but the problem occurs anyway.

The issue is that when the SQL string has more than one command and it has a syntax error somewhere, no exception is thrown. Even without try catch, when calling the action directly on the browser, no exception or error is thrown.

Anyway, I found out that if I split each sql command and call them individually, It works as expected

       try {
            $conn->begin();
            foreach ($sqls as $sql) {
                $stmt=$conn->prepare($sql);   
                $stmt->execute([]);
            }
            $conn->commit();   

       } catch (\PDOException  $e) {
            pr("PDOException");

        }