pdo catch and output mysql errors

后端 未结 3 471
时光说笑
时光说笑 2021-02-07 20:52

Still trying to get my head around pdo.

I have an insert statement that is executed with pdo. insert works great however if there is an error I would like it displayed t

3条回答
  •  长发绾君心
    2021-02-07 21:11

    You should use this:

    return $exception->getMessage();
    

    See the page on the documentation of Exception class:

    http://www.php.net/manual/en/exception.getmessage.php

提交回复
热议问题