php - Mysql INSERT ... ON DUPLICATE KEY UPDATE responce -


Hello, I have a table A and I want to insert a new value (not updated) INSERT to that table. In Table B, I tried to play with the response to the query $ INSERT. No luck on the update of duplicates, it always returns 1.

  $ query = "Include in table" $ field. "value". $ Value "Duplicate Key Update Update = 1" $ response = $ dbc-> Query ($ query); If ($ response == 1)  

I have also tried a 'hack', it is to say that to put an update on INSERT, if the entry does not exist for failure , But he returns 1 each time again.

  $ query = "Update table SET update = 1;; $ response = $ dbc- & gt; query ($ query); if ($ response == 1)  

This should work:

  & lt ;? php $ Link = Mysqli_connect ("localhost", "my_user", "my_password", "world"); mysqli_query ($ link, "tableA" INSERT. $ Field. "Value". $ Value. "Duplicate Key Update Update = 1 "On); if (mysqli_affected_rows ($ link) == 1) {mysqli_query ($ link," enter in table ". $ Field." Value ". $ Value.); }? & Gt;  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -