PHP Email if SQL entry is new, no email if update

前端 未结 1 1981
离开以前
离开以前 2021-01-23 07:56

I have an email that gets sent out (via PHPMailer) when a new user is added to a database. The DB is updated if the email (key) already exists with the ON DUPLICATE KEY UPDATE f

相关标签:
1条回答
  • 2021-01-23 08:21

    As per the docs: https://dev.mysql.com/doc/refman/5.1/en/mysql-affected-rows.html

    For INSERT ... ON DUPLICATE KEY UPDATE statements, the affected-rows value is 1 if the row is inserted as a new row and 2 if an existing row is updated.

    So, use: mysql_affected_rows, or whatever equivalent is on your non-deprecated/non-obsolete DB library of choice.

    0 讨论(0)
提交回复
热议问题