title: Insert or update if already exists - prepared statement
body: <p>I have found answers all over the place on how to INSERT or UPDATE if record already exists, a good approach is using the <code>on duplicate key update</code> or REPLACE, but I can't seem to find anywhere how to do this using a prepared statement. Is this possible?</p>
  
  <p>EDIT:</p>
  
  <p>Ok let me be more specific with my question:</p>
  
  <p>If I have a mysqli prepared statement like this example:</p>
  
  <pre><code>if ($stmt = $mysqli-&gt;prepare("UPDATE test SET name= ?, age= ? WHERE iduser= ?")) {    
      $stmt-&gt;bind_param('ssi', $name, $age, $id);
      $stmt-&gt;execute();
  }
  </code></pre>
  
  <p>In this case how can I build a <code>on duplicate key update</code>
  This is were Im stuck, I dont know how to use the "?" :</p>
  
  <pre><code>if ($stmt = $mysqli-&gt;prepare("INSERT INTO test (iduser, name, age) VALUES (?,?,?))){
  ON DUPLICATE KEY UPDATE name=?,age=?")) {    
      $stmt-&gt;bind_param('iss', $id, $name, $age);
      $stmt-&gt;execute();
  }
  </code></pre>