title: Fastest way to update a MySQL table if row exists else insert. More than 2 non-unique keys
body: <p>I have the following table structure:</p>
  
  <pre><code> CREATE TABLE IF NOT EXISTS `reports` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `day` int(11) NOT NULL,
    `uid` int(11) NOT NULL,
    `siteid` int(11) NOT NULL,
    `cid` int(3) NOT NULL,
    `visits` int(11) NOT NULL,
    PRIMARY KEY (`id`)
   )
  </code></pre>
  
  <p>Currently i check &amp; insert/update with the following snippet:</p>
  
  <pre><code> $checkq = mysql_query("SELECT count(*) as rowexist FROM reports WHERE day='$day' AND uid='$uid' AND siteid='$sid' AND cid='$cid'") or die(mysql_error()); 
  $checkr = mysql_fetch_array($checkq);
  
  if ($checkr['rowexist'] &gt; 0) {
   mysql_query("UPDATE reports_adv SET visits=visits+1 WHERE  day='$day' AND uid='$uid' AND siteid='$sid' AND cid='$cid'"); 
  } else {
   mysql_query("INSERT INTO reports_adv SET day='$day', uid='$uid', siteid='$sid', cid='$cid', visits='1'");
  }
  </code></pre>
  
  <p>Is a fastest way to update this MySQL table if row exists else insert with more than 2 non-unique keys?</p>