How can I get an error when running multiple queries with PDO?

前端 未结 3 1811
逝去的感伤
逝去的感伤 2021-01-05 06:24

I\'m running multiple queries using PDO. If the second query fails, now Exception is thrown.

$db = new PDO(\"mysql:host=localhost;dbname=test\", \'root\', \         


        
3条回答
  •  佛祖请我去吃肉
    2021-01-05 07:17

    There's no clear&easy way to do that.

    I think, the best way is to read dump file query-by-query and execute one query at a time.

    You can also parse error message and extract problem line number if DB driver tells it (like 'unknown identifier 'blabla' on line 666').

提交回复
热议问题