REPLACE INTO should only be used if the data deletion is wanted.
[platal.git] / include / validations / medals.inc.php
index df04da6..dbfbb4b 100644 (file)
@@ -100,8 +100,9 @@ class MedalReq extends ProfileValidate
 
     public function commit ()
     {
-        return XDB::execute('REPLACE INTO  profile_medals
-                                   VALUES  ({?}, {?}, {?})',
+        return XDB::execute('INSERT INTO  profile_medals (pid, mid, gid)
+                                  VALUES  ({?}, {?}, {?})
+                 ON DUPLICATE KEY UPDATE  gid = VALUES(gid)',
                             $this->profile->id(), $this->mid,
                             is_null($this->gid) ? 0 : $this->gid);
     }