From 06158570c511ae349ce11c89ca769e98b69c408e Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sat, 23 Apr 2016 11:13:55 +0200 Subject: [PATCH] Only use "on duplicate key update" insert statement on MySQL connections. (SQLite does not support this statement) --- weave_storage.php | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/weave_storage.php b/weave_storage.php index caf0acd..bf5cbdc 100644 --- a/weave_storage.php +++ b/weave_storage.php @@ -24,6 +24,7 @@ # Toby Elliott (telliott@mozilla.com) # balu # Daniel Triendl +# Moonchild # # Alternatively, the contents of this file may be used under the terms of # either the GNU General Public License Version 2 or later (the "GPL"), or @@ -220,12 +221,21 @@ class WeaveStorage try { - $insert_stmt = 'insert into wbo (username, id, collection, parentid, predecessorid, sortindex, modified, payload, payload_size) - values (:username, :id, :collection, :parentid, :predecessorid, :sortindex, :modified, :payload, :payload_size) - on duplicate key update - username=values(username), id=values(id), collection=values(collection), parentid=values(parentid), - predecessorid=values(predecessorid), sortindex=values(sortindex), modified=values(modified), payload=values(payload), - payload_size=values(payload_size)'; + if ( MYSQL_ENABLE ) + { + $insert_stmt = 'insert into wbo (username, id, collection, parentid, predecessorid, sortindex, modified, payload, payload_size) + values (:username, :id, :collection, :parentid, :predecessorid, :sortindex, :modified, :payload, :payload_size) + on duplicate key update + username=values(username), id=values(id), collection=values(collection), parentid=values(parentid), + predecessorid=values(predecessorid), sortindex=values(sortindex), modified=values(modified), payload=values(payload), + payload_size=values(payload_size)'; + } + else + { + $insert_stmt = 'replace into wbo (username, id, collection, parentid, predecessorid, sortindex, modified, payload, payload_size) + values (:username, :id, :collection, :parentid, :predecessorid, :sortindex, :modified, :payload, :payload_size)'; + } + $sth = $this->_dbh->prepare($insert_stmt); $username = $this->_username;