PHP Try and Catch for SQL Insert

前端 未结 9 995
南方客
南方客 2020-12-15 18:05

I have a page on my website (high traffic) that does an insert on every page load.

I am curious of the fastest and safest way to (catch an error) and continue if the

9条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-15 18:10

    mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
    

    I am not sure if there is a mysql version of this but adding this line of code allows throwing mysqli_sql_exception.
    I know, passed a lot of time and the question is already checked answered but I got a different answer and it may be helpful.

提交回复
热议问题