REPLACE INTO should only be used if the data deletion is wanted.
[platal.git] / include / validations / photos.inc.php
index 60b6ae1..665c5d2 100644 (file)
@@ -137,8 +137,10 @@ class PhotoReq extends ProfileValidate
 
     public function commit()
     {
-        XDB::execute('REPLACE INTO  profile_photos (pid, attachmime, attach, x, y)
-                            VALUES  ({?},{?},{?},{?},{?})',
+        XDB::execute('INSERT INTO  profile_photos (pid, attachmime, attach, x, y)
+                           VALUES  ({?}, {?}, {?}, {?}, {?})
+          ON DUPLICATE KEY UPDATE  attachmime = VALUES(attachmime), attach = VALUES(attach)
+                                   x = VALUES(x), y = VALUES(y)',
                      $this->profile->id(), $this->mimetype, $this->data, $this->x, $this->y);
 
         return true;